-
Notifications
You must be signed in to change notification settings - Fork 155
[FOLLOW-UP #788] Normalise default-scheme ports (443/80/22) on DependencyReference / HostInfo #797
Copy link
Copy link
Open
Labels
area/cliCLI command surface, flags, help text (cross-cutting).CLI command surface, flags, help text (cross-cutting).area/lockfileLockfile schema, per-file provenance, integrity hashes, drift detection.Lockfile schema, per-file provenance, integrity hashes, drift detection.priority/highShips in current or next milestoneShips in current or next milestonestatus/acceptedDirection approved, safe to start work.Direction approved, safe to start work.status/triagedInitial agentic triage complete; pending maintainer ratification (silence = approval).Initial agentic triage complete; pending maintainer ratification (silence = approval).theme/securitySecure by default. Content scanning, lockfile integrity, MCP trust boundaries.Secure by default. Content scanning, lockfile integrity, MCP trust boundaries.type/bugSomething does not work as documented.Something does not work as documented.
Milestone
Metadata
Metadata
Assignees
Labels
area/cliCLI command surface, flags, help text (cross-cutting).CLI command surface, flags, help text (cross-cutting).area/lockfileLockfile schema, per-file provenance, integrity hashes, drift detection.Lockfile schema, per-file provenance, integrity hashes, drift detection.priority/highShips in current or next milestoneShips in current or next milestonestatus/acceptedDirection approved, safe to start work.Direction approved, safe to start work.status/triagedInitial agentic triage complete; pending maintainer ratification (silence = approval).Initial agentic triage complete; pending maintainer ratification (silence = approval).theme/securitySecure by default. Content scanning, lockfile integrity, MCP trust boundaries.Secure by default. Content scanning, lockfile integrity, MCP trust boundaries.type/bugSomething does not work as documented.Something does not work as documented.
Type
Projects
Status
Todo
Follow-up from the #788 review panel — devx-ux-expert finding #2.
Problem
`HostInfo.display_name` (and the corresponding `[i]` hint in `build_error_context`) renders `host:port` whenever `port is not None`. But the parser at `DependencyReference.parse` happily stores the explicit port from URLs like `https://github.com:443/owner/repo\` or `ssh://git@gitlab.com:22/owner/repo.git` — both are default-scheme ports that carry no semantic difference from the bare URL.
Result: a user who writes `https://github.com:443/owner/repo\` would see error text saying `Authentication failed for clone on github.com:443.` and an `[i] Host 'github.com:443' -- verify your credential helper stores per-port entries` hint that is irrelevant for that user (github.com on port 443 is the default).
The truthy → `is not None` change in #788 did not address this — `port=443` is non-`None`, so both forms render the same way.
Proposed fix
Two equally valid layers:
Option A — normalise at parse time (`DependencyReference.parse` / `_parse_ssh_protocol_url` / `_parse_standard_url`):
```python
DEFAULT_PORTS = {"https": 443, "http": 80, "ssh": 22}
if port == DEFAULT_PORTS.get(scheme):
port = None
```
Option B — normalise at `HostInfo.post_init`:
A frozen-dataclass-friendly equivalent of A, scoped to whichever scheme `HostInfo` is constructed for. Slightly trickier because `HostInfo` doesn't currently know the scheme.
Option A is more direct (the port comes off the URL, the URL has a scheme right there) and keeps `HostInfo` scheme-agnostic. Recommend A.
Required tests
A unit test pinning the contract for each transport:
```python
def test_default_https_port_normalised_to_none():
dep = DependencyReference.parse("https://github.com:443/owner/repo\")
assert dep.port is None
def test_default_ssh_port_normalised_to_none():
dep = DependencyReference.parse("ssh://git@gitlab.com:22/owner/repo.git")
assert dep.port is None
def test_non_default_port_preserved():
dep = DependencyReference.parse("https://bitbucket.corp.com:7990/team/repo\")
assert dep.port == 7990
```
And the existing `test_https_url_with_port_capture` style tests stay green.
Refs