Skip to content

[BUG] is_generic clone/ls-remote error path renders bare host, losing custom port for Bitbucket DC users #798

@edenfunf

Description

@edenfunf

Follow-up from PR #788 review panel -- cli-logging-expert finding #3, confirmed pre-existing and not introduced by #788.

Describe the bug

When a generic (non-GitHub, non-ADO) host fails during clone or git ls-remote, the error message drops the port on `dep_host`, so a user on Bitbucket Datacenter (or any self-hosted host using a custom port) sees:

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.

The port is the whole reason they are here -- hiding it from the diagnostic defeats the purpose of the PR #788 port-threading work for this specific error path.

Affected call sites (current main, after #788/#789 merge)

Both do:

```python
host_name = dep_host or "the target host"
error_msg += (
f"For private repositories on {host_name}, configure SSH keys or a git credential helper. "
...
)
```

`dep_host` is pulled straight off the dependency and never gains `:{port}`.

To Reproduce

  1. Configure an `apm.yml` with a Bitbucket DC-style SSH URL on a non-default port, e.g.
    `ssh://git@bitbucket.example.com:7999/team/repo.git`.
  2. Ensure credentials are missing or wrong so the clone fails.
  3. Run `apm install`.
  4. Observe the error message: `bitbucket.example.com` appears without the `:7999` suffix.

Expected behavior

Both error branches should render `{host}:{port}` when `dep_ref.port` is set -- using `host_info.display_name` from the `AuthResolver` path is the most consistent fix (it already handles the port-rendering convention used by the auth branch a few lines above at `:858`).

Suggested shape:

```python
host_info = self.auth_resolver.classify_host(dep_host, port=(dep_ref.port if dep_ref else None))
host_name = host_info.display_name if dep_host else "the target host"
```

Environment

  • Not environment-dependent; any caller that hits the `is_generic` branch with `dep_ref.port` set reproduces.

Additional context

  • The `AuthResolver.build_error_context` branch on the non-generic path already uses `host_info.display_name` (see `core/auth.py:374`), so aligning the generic branch closes the last internal asymmetry around port surfacing.
  • Scope-limited fix: no new signatures, no schema impact; only the two `host_name = dep_host or ...` lines change.

Refs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions