Skip to content

fix: improve multi-host error guidance when GITHUB_HOST is set#130

Merged
danielmeppiel merged 3 commits intomainfrom
fix/multi-host-github-host-113
Mar 3, 2026
Merged

fix: improve multi-host error guidance when GITHUB_HOST is set#130
danielmeppiel merged 3 commits intomainfrom
fix/multi-host-github-host-113

Conversation

@danielmeppiel
Copy link
Collaborator

Summary

Fixes #113 — when GITHUB_HOST is set to a corporate endpoint, shorthand dependencies (without an explicit hostname) resolve against that host. If a user mixes corporate and public GitHub deps without using FQDN, they get a confusing "Repository not found" error with no guidance.

Changes

1. Actionable error message for multi-host scenarios

When a clone fails and GITHUB_HOST is set, APM now detects whether the failing dependency inherited its host from GITHUB_HOST and suggests using FQDN syntax:

GITHUB_HOST is set to 'git.corporate.com', so shorthand dependencies
(without a hostname) resolve against that host. If this package lives
on a different server (e.g., github.com), use the full hostname in
apm.yml: github.com/owner/repo

2. Remove stale host state mutations

Removed two self.github_host = dep_ref.host assignments in GitHubDownloader that mutate instance state per-dependency. These are dead code (every call path passes dep_ref with a non-null host, so _build_repo_url always uses dep_ref.host directly), but they represent a state-pollution hazard if future refactoring introduced a code path without dep_ref.

3. Documentation

Added a callout in getting-started.md clarifying that GITHUB_HOST affects all bare package names, with a YAML example showing how to mix hosts.

Testing

  • All unit tests pass (682 passed)
  • All integration tests pass (682 passed)
  • No breaking changes — existing GITHUB_HOST behavior is preserved

- Remove stale self.github_host mutations that could leak host state
  across dependencies (dead code, but hazardous if reached)
- Add actionable error message when GITHUB_HOST is set and a clone fails,
  guiding users to use FQDN syntax for deps on other hosts
- Document multi-host behavior in getting-started.md

Closes #113
Copilot AI review requested due to automatic review settings March 2, 2026 19:52
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Improves user guidance for mixed GitHub host scenarios when GITHUB_HOST is set, reduces per-dependency state mutation in the GitHub downloader, and documents how to mix corporate and public GitHub dependencies safely.

Changes:

  • Add an actionable clone-failure hint explaining how GITHUB_HOST affects shorthand dependencies and how to use FQDN syntax.
  • Remove self.github_host = dep_ref.host assignments that mutate downloader instance state per dependency.
  • Update getting-started documentation with a callout and example for multi-host dependency configuration.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/apm_cli/deps/github_downloader.py Adds multi-host error guidance on clone failure; removes per-dependency host state mutations.
docs/getting-started.md Documents that GITHUB_HOST applies to bare dependency names and shows how to mix hosts via FQDN.
Comments suppressed due to low confidence (1)

src/apm_cli/deps/github_downloader.py:303

  • New error-message behavior was added for the multi-host scenario (GITHUB_HOST set + dep host matches) but there isn’t a unit test asserting this branch. Please add a test around _clone_with_fallback that forces all clone methods to fail and asserts (1) the guidance appears when GITHUB_HOST is set and dep_ref.host matches, and (2) it does not appear when the dependency explicitly targets a different host (e.g., github.com).
        configured_host = os.environ.get("GITHUB_HOST", "")
        dep_host = dep_ref.host if dep_ref else None
        if is_ado and not self.has_ado_token:
            error_msg += "For private Azure DevOps repositories, set ADO_APM_PAT environment variable."
        elif configured_host and dep_host and dep_host == configured_host and configured_host != "github.com":

@danielmeppiel danielmeppiel merged commit 7500bbb into main Mar 3, 2026
6 checks passed
@danielmeppiel danielmeppiel deleted the fix/multi-host-github-host-113 branch March 3, 2026 10:46
danielmeppiel added a commit that referenced this pull request Mar 3, 2026
- Bump version to 0.7.4
- Rewrite Unreleased changelog as v0.7.4 with clean style (no bold labels),
  consolidated CI/governance entries, Added → Fixed → Changed ordering
- Add missing PRs: #97 (hooks), #118 (governance), #119 (gh-aw upgrade), #130 (multi-host)
- README: fix APM Packages section — accurate installable types, doc links,
  fix anthropics/courses → anthropics/skills, remove Add yours row,
  note hooks in apm.yml example comment
@danielmeppiel danielmeppiel mentioned this pull request Mar 3, 2026
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] Forcing a url of ghe deny access to other github servers

4 participants