Skip to content

fix(install): surface custom port in generic host clone/ls-remote error#804

Open
edenfunf wants to merge 1 commit intomicrosoft:mainfrom
edenfunf:fix/clone-error-port-display
Open

fix(install): surface custom port in generic host clone/ls-remote error#804
edenfunf wants to merge 1 commit intomicrosoft:mainfrom
edenfunf:fix/clone-error-port-display

Conversation

@edenfunf
Copy link
Copy Markdown
Contributor

Description

The two is_generic error branches in github_downloader render the bare host in the "For private repositories on {host}" hint, dropping any custom port. Users on Bitbucket Datacenter (or any self-hosted host on a non-default port) see a diagnostic that hides the very detail they need to verify their git credential helper against:

For private repositories on bitbucket.corp.com, configure SSH keys or a git credential helper.

instead of:

For private repositories on bitbucket.corp.com:7999, configure SSH keys or a git credential helper.

Both branches now route through AuthResolver.classify_host(...).display_name, so the generic path shares port rendering with the adjacent ADO and auth branches (which already used build_error_contexthost_info.display_name). This also means any future refinement to HostInfo.display_name (e.g. default-port normalisation, tracked in #797) propagates to these two call sites for free.

Scope-limited per the issue: no new signatures, no schema impact; only the two host_name = dep_host or "..." lines change. The "the target host" fallback is kept for the (unreachable-today but defensive) dep_host=None case, mirroring the dep_ref.port if dep_ref else None guard already used at the neighbouring auth call sites.

Fixes #798

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)

New regression tests in tests/unit/test_generic_host_error_port.py cover both error branches with three shapes each: ssh custom port (Bitbucket DC 7999), https custom port (Bitbucket DC 7990), and a no-port control that guards against spurious : suffixes. Temporarily reverting the fix turns the four port-bearing assertions red with the exact bare-host string described in the issue, then green again once the fix is reapplied -- the tests bite on the regression they're named after.

Manual verification with ssh://git@bitbucket.nonexistent-host.example:7999/team/repo.git:

Failed to clone repository team/repo via SSH. ...
For private repositories on bitbucket.nonexistent-host.example:7999, configure SSH keys or a git credential helper.
APM delegates authentication to git for non-GitHub/ADO hosts.

pytest tests/unit -q → 4449 passed, 0 new failures. The three pre-existing failures in tests/test_github_downloader.py reproduce on origin/main without this patch and are unrelated.

The two is_generic error branches in github_downloader rendered the
bare host, dropping ``:{port}`` from the ``"For private repositories
on {host}"`` hint. Users on Bitbucket Datacenter (or any self-hosted
host using a non-default port) saw a diagnostic that hid the very
detail they needed to verify their git credential helper against.

Route both branches through ``AuthResolver.classify_host(...).display_name``
so the generic path shares port rendering with the adjacent ADO and
auth branches (which already used ``build_error_context`` ->
``host_info.display_name``). Keep the ``"the target host"`` fallback
for the (unreachable-today but defensive) ``dep_host=None`` case, and
mirror the ``dep_ref.port if dep_ref else None`` guard used at the
neighbouring call sites.

Scope-limited: no new signatures, no schema impact; only the two
``host_name = dep_host or "..."`` lines change.

Regression tests in tests/unit/test_generic_host_error_port.py cover
both call sites with ssh/https custom port and a no-port control.

Closes microsoft#798
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] is_generic clone/ls-remote error path renders bare host, losing custom port for Bitbucket DC users

1 participant