fix: reject host-less catalog URLs in base and preset validators (#3209) (#3227)

`CatalogStackBase._validate_catalog_url` (inherited by `IntegrationCatalog`)
and `PresetCatalog._validate_catalog_url` checked `parsed.netloc`, which is
truthy for host-less URLs like `https://:8080` (port only) or `https://user@`
(userinfo only). Such URLs slipped past validation despite the error message
promising "a valid URL with a host", then failed later with a confusing fetch
error.

Switch both validators to `parsed.hostname` (None for those inputs), matching
the workflow, step, and bundler catalog validators that already do this.

Add regression tests covering port-only and userinfo-only URLs for both
validators.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Noor ul ain
2026-06-30 17:18:39 +05:00
committed by GitHub
parent 8025481eca
commit cb7c36c95b
4 changed files with 14 additions and 12 deletions

View File

@@ -80,7 +80,7 @@ class CatalogStackBase:
)
# Check hostname, not netloc: netloc is truthy for host-less URLs like
# "https://:8080" or "https://user@", so the host guarantee this error
# promises would not actually hold. hostname is None in those cases.
# promises would not actually hold. hostname is None in those cases (#3209).
if not parsed.hostname:
raise cls._error("Catalog URL must be a valid URL with a host.")

View File

@@ -1863,7 +1863,7 @@ class PresetCatalog:
)
# Check hostname, not netloc: netloc is truthy for host-less URLs like
# "https://:8080" or "https://user@", so the host guarantee this error
# promises would not actually hold. hostname is None in those cases.
# promises would not actually hold. hostname is None in those cases (#3209).
if not parsed.hostname:
raise PresetValidationError(
"Catalog URL must be a valid URL with a host."