Skip to content

fix(bundler): reject host-less catalog URLs in adapters (use hostname, not netloc)#3333

Open
Quratulain-bilal wants to merge 1 commit into
github:mainfrom
Quratulain-bilal:fix/adapters-hostless-url
Open

fix(bundler): reject host-less catalog URLs in adapters (use hostname, not netloc)#3333
Quratulain-bilal wants to merge 1 commit into
github:mainfrom
Quratulain-bilal:fix/adapters-hostless-url

Conversation

@Quratulain-bilal

@Quratulain-bilal Quratulain-bilal commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

fixes #3332

what

_validate_remote_url in bundler/services/adapters.py guarded on parsed.netloc, which is truthy for host-less URLs (https://:8080, https://user@) even though they carry no host — so they passed the "must be a valid URL with a host" check. the docstring says it mirrors specify_cli.catalogs validation, but that site was fixed to use hostname in #3210/#3227 and this twin was missed.

how

check parsed.hostname (None for host-less URLs) instead of parsed.netloc, matching catalogs.py. this guard runs before any network call, so it's a pre-flight safety check.

reproduction (fixed)

_validate_remote_url("team", "https://:8080")   # before: accepted -> after: rejected
_validate_remote_url("team", "https://user@")   # before: accepted -> after: rejected
_validate_remote_url("team", "https://example.com:8080/c.json")  # still accepted

tests

added parametrized regression tests for the host-less forms (https://:8080, https://:0, https://user@, https://user:pw@, https://:8080/catalog.json) plus a valid host+port sanity case. verified they fail on the current code and pass with the fix; the full adapters test file pas

…, not netloc)

_validate_remote_url in bundler/services/adapters.py guarded on parsed.netloc,
which is truthy for host-less URLs like "https://:8080" or "https://user@" even
though they carry no host. so those passed the "must be a valid URL with a host"
check. its docstring says it mirrors specify_cli.catalogs validation, but that
site was already fixed to use hostname in github#3210/github#3227 and this twin was missed.

switch to parsed.hostname (None for host-less URLs), matching catalogs.py. this
guard runs before any network call, so it is a pre-flight safety check.

add parametrized regression tests for the host-less forms plus a valid
host+port sanity case.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a URL validation gap in the bundler catalog adapter by rejecting “host-less” HTTPS URLs (e.g. https://:8080, https://user@) that previously slipped through due to relying on urlparse(...).netloc rather than hostname. This aligns bundler behavior with the established validator behavior in specify_cli.catalogs.

Changes:

  • Update _validate_remote_url to require parsed.hostname (not parsed.netloc) so port-only/userinfo-only URLs are rejected.
  • Add regression tests covering multiple host-less URL shapes plus a valid host+port sanity case.
Show a summary per file
File Description
src/specify_cli/bundler/services/adapters.py Tightens pre-flight remote URL validation by checking parsed.hostname to correctly reject host-less URLs.
tests/unit/test_bundler_adapters.py Adds parametrized regression tests for host-less URL forms and one valid host+port case.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Low

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: bundler adapters accept host-less catalog URLs (https://:8080), unlike catalogs.py

3 participants