fix: doctor survives a Redis URL whose port will not parse

urlsplit accepts redis://host:notaport/0; only parts.port raises, and it raises
on access rather than at split time, so the ValueError fell outside the try.
_check_redis catches the client error and then formats it through _endpoint, so
doctor ended with a traceback from inside its own error path.
This commit is contained in:
Alex committed 2026-09-17 12:12:28 +01:00
1 parent 1cce6cfd67
commit 66fbb11049
2 files changed
+25 -6

No files matched your search

+5 -4
View File
@@ -815,12 +815,13 @@ def _endpoint(url: str) -> str:
"""A URL without its credentials: this ends up on a terminal, in CI logs and in issues."""
try:
parts = urlsplit(url)
# .port is a property that parses on access, so it raises separately from the split itself.
host, port, scheme, path = parts.hostname or "", parts.port, parts.scheme, parts.path
except ValueError:
return "the configured URL"
host = parts.hostname or ""
if parts.port:
host = f"{host}:{parts.port}"
return f"{parts.scheme}://{host}{parts.path}" if host else "the configured URL"
if port:
host = f"{host}:{port}"
return f"{scheme}://{host}{path}" if host else "the configured URL"
def _scrub(text: str, url: Optional[str]) -> str: