fix: ensure githubnext/agentics resolves to github.com when GHE is configured#22014
fix: ensure githubnext/agentics resolves to github.com when GHE is configured#22014
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> Agent-Logs-Url: https://github.com/github/gh-aw/sessions/d55f95d1-71d5-4ae6-9c39-50c8195e5e69
…mode When GH_HOST is set to a non-github.com GHE host, short-form workflow specs like `githubnext/agentics/workflow-name` would be resolved against the GHE host instead of github.com. - getGitHubHostForRepo: add githubnext/agentics to the list of repos that always use https://github.com (covers git-based downloads) - parseWorkflowSpec: set Host: "github.com" when the slug is githubnext/agentics or github/gh-aw (covers API-based downloads) - Update CLI help-text examples to use full https://github.com/... URLs - Update schema examples to use full URLs Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> Agent-Logs-Url: https://github.com/github/gh-aw/sessions/d55f95d1-71d5-4ae6-9c39-50c8195e5e69
|
@copilot only apply this optimization when a GHE environment is detected, otherwise keep the shorter intuitive syntax. |
- Revert help text examples in add/add-wizard/trial commands to the shorter githubnext/agentics/... syntax (keep intuitive form for non-GHE users) - Revert schema examples to shorter form - In parseWorkflowSpec, only set Host: "github.com" when a non-github.com GHE host is detected via getGitHubHost() Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> Agent-Logs-Url: https://github.com/github/gh-aw/sessions/e1234e84-e2a8-467e-bb4e-a69ac58e56ed
Done in 60a7874. The |
There was a problem hiding this comment.
Pull request overview
Fixes workflow-spec host resolution so that githubnext/agentics/... (and github/gh-aw/...) correctly targets github.com even when a GitHub Enterprise host is configured via GH_HOST, preventing fetch failures.
Changes:
- Pins
githubnext/agenticsto the public GitHub host in repo-host resolution for git-based downloads. - Updates workflow spec parsing to explicitly set
WorkflowSpec.Host = "github.com"forgithubnext/agenticsandgithub/gh-awwhen a GHE host is detected, ensuring API-based downloads target the correct server. - Updates a locked CI workflow’s safe-output tool schema and action inputs for adding the “smoked” label.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| pkg/cli/spec.go | Adds GHE-aware host pinning for known public-only repos in parseWorkflowSpec (API fetch path). |
| pkg/cli/github.go | Extends getGitHubHostForRepo allowlist to include githubnext/agentics (git fetch path). |
| .github/workflows/smoke-codex.lock.yml | Modifies safe-output tool schema and wiring for the “add smoked label” step. |
Comments suppressed due to low confidence (1)
.github/workflows/smoke-codex.lock.yml:472
- This PR is described as fixing GH host resolution for githubnext/agentics under GHE, but it also changes the smoke-codex locked workflow’s safe-outputs tool schema and action inputs. If this change is intentional, it should be called out in the PR description (or moved to a separate PR) to keep scope clear and ease review/auditing of workflow changes.
{
"description": "Add the 'smoked' label to the current pull request (can only be called once)",
"inputSchema": {
"additionalProperties": false,
"properties": {
"labels": {
"description": "The labels' name to be added. Must be separated with line breaks if there're multiple labels.",
"type": "string"
},
"number": {
"description": "The number of the issue or pull request.",
"type": "string"
}
},
"required": [
"labels"
],
"type": "object"
},
"name": "add_smoked_label"
}
]
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
pkg/cli/spec.go
Outdated
| // When a GHE instance is configured, certain well-known repositories that exist only | ||
| // on public GitHub must have their host pinned to github.com so that API fetches target | ||
| // the correct server instead of the GHE instance. | ||
| var explicitHost string | ||
| if getGitHubHost() != string(constants.PublicGitHubHost) { | ||
| if repoSlug == "githubnext/agentics" || repoSlug == "github/gh-aw" { | ||
| explicitHost = "github.com" | ||
| } | ||
| } |
There was a problem hiding this comment.
The host-pinning allowlist and GHE detection logic is duplicated here instead of reusing the existing host-resolution helper (e.g., getGitHubHostForRepo). Consider centralizing the “repos that must always use public GitHub” mapping in one place and deriving the correct API host from constants.PublicGitHubHost (parse URL -> hostname) to avoid hard-coded "github.com" strings and future drift between code paths.
pkg/cli/spec.go
Outdated
| // When a GHE instance is configured, certain well-known repositories that exist only | ||
| // on public GitHub must have their host pinned to github.com so that API fetches target | ||
| // the correct server instead of the GHE instance. | ||
| var explicitHost string | ||
| if getGitHubHost() != string(constants.PublicGitHubHost) { | ||
| if repoSlug == "githubnext/agentics" || repoSlug == "github/gh-aw" { | ||
| explicitHost = "github.com" | ||
| } | ||
| } |
There was a problem hiding this comment.
New behavior: when a non-public GH host is configured, specs targeting githubnext/agentics or github/gh-aw get Host pinned to github.com. There are unit tests for parseWorkflowSpec in pkg/cli/spec_test.go, but none that set GH_HOST (or related env vars) to a GHE value and assert spec.Host is set for these repo slugs. Add tests for both normal and wildcard specs under a simulated enterprise host to prevent regressions.
| // getGitHubHostForRepo returns the GitHub host URL for a specific repository. | ||
| // The gh-aw repository (github/gh-aw) always uses public GitHub (https://github.com) | ||
| // regardless of enterprise GitHub host settings, since gh-aw itself is only available | ||
| // on public GitHub. For all other repositories, it uses getGitHubHost(). | ||
| // The gh-aw repository (github/gh-aw) and the agentics workflow library | ||
| // (githubnext/agentics) always use public GitHub (https://github.com) | ||
| // regardless of enterprise GitHub host settings, since these repositories are | ||
| // only available on public GitHub. For all other repositories, it uses getGitHubHost(). | ||
| func getGitHubHostForRepo(repo string) string { | ||
| // The gh-aw repository is always on public GitHub | ||
| if repo == "github/gh-aw" || strings.HasPrefix(repo, "github/gh-aw/") { | ||
| githubLog.Print("Using public GitHub host for github/gh-aw repository") | ||
| return string(constants.PublicGitHubHost) | ||
| } | ||
|
|
||
| // The agentics workflow library is always on public GitHub | ||
| if repo == "githubnext/agentics" || strings.HasPrefix(repo, "githubnext/agentics/") { | ||
| githubLog.Print("Using public GitHub host for githubnext/agentics repository") | ||
| return string(constants.PublicGitHubHost) | ||
| } |
There was a problem hiding this comment.
getGitHubHostForRepo now treats githubnext/agentics as always hosted on public GitHub, but there are no unit tests covering this function (pkg/cli/github_test.go only tests getGitHubHost). Add tests that set GH_HOST to a GHE host and verify getGitHubHostForRepo("githubnext/agentics") (and prefixed paths) returns constants.PublicGitHubHost while non-allowlisted repos return the configured enterprise host.
| } | ||
| }, | ||
| "required": [ | ||
| "labels" |
There was a problem hiding this comment.
The add_smoked_label tool schema doesn’t require the "number" field, but the workflow step later always reads .number from the payload and passes it to action-add-labels. If the payload omits number, this will resolve to null/empty and likely break labeling. Either make "number" required in the schema or update the step/action to not depend on it (e.g., derive the PR number from context).
| "labels" | |
| "labels", | |
| "number" |
| "payload": { | ||
| "description": "JSON-encoded payload to pass to the action", | ||
| "labels": { | ||
| "description": "The labels' name to be added. Must be separated with line breaks if there're multiple labels.", |
There was a problem hiding this comment.
Minor grammar in the new tool schema description: "Must be separated with line breaks if there're multiple labels" should be corrected (e.g., "if there are multiple labels"). Clearer phrasing also helps automated-tool consumers interpret the field consistently.
| "description": "The labels' name to be added. Must be separated with line breaks if there're multiple labels.", | |
| "description": "The label names to add, separated by line breaks if there are multiple labels.", |
|
@copilot review comments |
…x lock yml - spec.go: replace duplicated allowlist with getGitHubHostForRepo() call; derive hostname by parsing URL instead of hard-coding "github.com" - github_test.go: add TestGetGitHubHostForRepo covering allowlisted and non-allowlisted repos with and without GHE configured - spec_test.go: add TestParseWorkflowSpecGHEHostPinning and TestParseWorkflowSpecNoGHEHostPinning to prevent regressions - smoke-codex.lock.yml: make "number" required in add_smoked_label schema; fix grammar "there're" -> "there are" Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> Agent-Logs-Url: https://github.com/github/gh-aw/sessions/3781b8df-791b-49e8-8d11-97c82d95032a
Addressed all review comments in 321e9e2:
|
Summary
When
GH_HOSTis configured to a non-github.comGHE host, short-form workflow specs likegithubnext/agentics/workflow-namewere resolved against the GHE host instead of github.com, causing fetches to fail.Changes
Core fix
pkg/cli/github.go: Addedgithubnext/agenticstogetGitHubHostForRepoalongsidegithub/gh-aw, so that git-based workflow downloads always targethttps://github.comfor this repo when GHE is active.pkg/cli/spec.go: InparseWorkflowSpec, delegates host resolution togetGitHubHostForRepo()(centralizing the allowlist) and derives the explicit hostname by parsing the returned URL — eliminating duplicated logic and hard-coded"github.com"strings. The explicit host is only set when a GHE environment is detected, leaving the standard github.com flow unchanged.The shorter
githubnext/agentics/...syntax continues to work as-is for public GitHub users — no help text or schema changes are made.Tests
pkg/cli/github_test.go: AddedTestGetGitHubHostForRepocovering allowlisted repos (githubnext/agentics,github/gh-aw) with and without GHE configured, repos with sub-paths, and non-allowlisted repos.pkg/cli/spec_test.go: AddedTestParseWorkflowSpecGHEHostPinning(verifiesHostis pinned to"github.com"in GHE mode for allowlisted repos, empty for others) andTestParseWorkflowSpecNoGHEHostPinning(verifies no pinning on standard github.com).Lock file fix
.github/workflows/smoke-codex.lock.yml: Made"number"a required field in theadd_smoked_labeltool schema to prevent null payloads breaking the labeling step; fixed grammar in field description ("there're"→"there are").📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.