Skip to content

fix: ensure githubnext/agentics resolves to github.com when GHE is configured#22014

Merged
pelikhan merged 6 commits intomainfrom
copilot/update-agentics-url-for-ghe
Mar 20, 2026
Merged

fix: ensure githubnext/agentics resolves to github.com when GHE is configured#22014
pelikhan merged 6 commits intomainfrom
copilot/update-agentics-url-for-ghe

Conversation

Copy link
Contributor

Copilot AI commented Mar 20, 2026

Summary

When GH_HOST is configured to a non-github.com GHE host, short-form workflow specs like githubnext/agentics/workflow-name were resolved against the GHE host instead of github.com, causing fetches to fail.

Changes

Core fix

  • pkg/cli/github.go: Added githubnext/agentics to getGitHubHostForRepo alongside github/gh-aw, so that git-based workflow downloads always target https://github.com for this repo when GHE is active.
  • pkg/cli/spec.go: In parseWorkflowSpec, delegates host resolution to getGitHubHostForRepo() (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: Added TestGetGitHubHostForRepo covering 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: Added TestParseWorkflowSpecGHEHostPinning (verifies Host is pinned to "github.com" in GHE mode for allowlisted repos, empty for others) and TestParseWorkflowSpecNoGHEHostPinning (verifies no pinning on standard github.com).

Lock file fix

  • .github/workflows/smoke-codex.lock.yml: Made "number" a required field in the add_smoked_label tool 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.

Copilot AI and others added 2 commits March 20, 2026 18:36
…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
@pelikhan
Copy link
Contributor

@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
Copy link
Contributor Author

Copilot AI commented Mar 20, 2026

@copilot only apply this optimization when a GHE environment is detected, otherwise keep the shorter intuitive syntax.

Done in 60a7874. The Host: "github.com" pin in parseWorkflowSpec is now conditional on getGitHubHost() returning a non-github.com value — so the shorter githubnext/agentics/... form is kept in help text and works as before for public GitHub users. The explicit host is only injected when a GHE environment is detected.

Copilot AI changed the title fix: ensure githubnext/agentics always resolves to github.com in GHE mode fix: ensure githubnext/agentics resolves to github.com when GHE is configured Mar 20, 2026
@pelikhan pelikhan marked this pull request as ready for review March 20, 2026 19:08
Copilot AI review requested due to automatic review settings March 20, 2026 19:08
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

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/agentics to the public GitHub host in repo-host resolution for git-based downloads.
  • Updates workflow spec parsing to explicitly set WorkflowSpec.Host = "github.com" for githubnext/agentics and github/gh-aw when 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
Comment on lines +299 to +307
// 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"
}
}
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
pkg/cli/spec.go Outdated
Comment on lines +299 to +307
// 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"
}
}
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines 38 to +54
// 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)
}
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
}
},
"required": [
"labels"
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

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).

Suggested change
"labels"
"labels",
"number"

Copilot uses AI. Check for mistakes.
"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.",
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
"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 uses AI. Check for mistakes.
@pelikhan
Copy link
Contributor

@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
Copy link
Contributor Author

Copilot AI commented Mar 20, 2026

@copilot review comments

Addressed all review comments in 321e9e2:

  • spec.go: Removed duplicated allowlist — now delegates to getGitHubHostForRepo() and derives the hostname by parsing the returned URL, eliminating the hard-coded "github.com" string and keeping the two code paths in sync automatically.
  • github_test.go: Added TestGetGitHubHostForRepo covering allowlisted repos (githubnext/agentics, github/gh-aw) with/without GHE configured, and non-allowlisted repos.
  • spec_test.go: Added TestParseWorkflowSpecGHEHostPinning (verifies Host is pinned to github.com in GHE mode for allowlisted repos, empty for others) and TestParseWorkflowSpecNoGHEHostPinning (verifies no pinning on standard github.com).
  • smoke-codex.lock.yml: Added "number" to the add_smoked_label required fields; fixed grammar ("there're""there are").

@pelikhan pelikhan merged commit 87e8945 into main Mar 20, 2026
53 checks passed
@pelikhan pelikhan deleted the copilot/update-agentics-url-for-ghe branch March 20, 2026 20:40
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.

3 participants