Skip to content

[plan] Add GHE host auto-detection to compile command for correct repo validation #40005

@github-actions

Description

@github-actions

Problem

The gh aw add and gh aw audit commands call getHostFromOriginRemote() to auto-detect when the git remote is a GitHub Enterprise Server host, then call workflow.SetDefaultGHHost(detectedHost) so that subsequent gh api calls target the correct GHE instance.

The gh aw compile command does not do this. When a user on a GHE instance runs gh aw compile --validate without setting GH_HOST, repo validation calls (checkRepositoryHasIssuesUncached, checkRepositoryHasDiscussionsUncached) use the gh CLI's default configuration, which may silently target the wrong host.

Additionally, without SetDefaultGHHost being called, the SkipHardcodedFallback check in PinContext() (even after the companion fix to check getDefaultGHHost()) won't activate for the compile command when GH_HOST env is unset.

Related issue: #39792

Fix

In the compile command's startup path (e.g., pkg/cli/compile_orchestrator.goCompileWorkflows), add GHE host auto-detection identical to what add_interactive_orchestrator.go does:

// Auto-detect GHE host from git remote when GH_HOST is not set
if os.Getenv("GH_HOST") == "" {
    if detectedHost := getHostFromOriginRemote(); detectedHost != "github.com" && detectedHost != "" {
        workflow.SetDefaultGHHost(detectedHost)
    }
}

This ensures:

  1. Repo validation queries target the correct GHE endpoint
  2. SkipHardcodedFallback is set correctly via PinContext() (after the companion fix)

Files to modify

  • pkg/cli/compile_orchestrator.go — add GHE host auto-detection at compile startup
  • pkg/cli/compile_orchestrator_stability_test.go or a new test file — add test verifying that SetDefaultGHHost is called when origin remote is a GHE host

Acceptance criteria

  • CompileWorkflows calls workflow.SetDefaultGHHost with the detected GHE host when the git remote is not github.com and GH_HOST env is unset
  • CompileWorkflows does NOT call workflow.SetDefaultGHHost when GH_HOST is already set in env
  • Does not change behavior when the git remote is github.com (public GitHub)
  • Existing tests still pass (make agent-report-progress)

Generated by 📋 Plan Command ·
Comment /plan to run again

  • expires on Jun 19, 2026, 10:26 PM UTC-08:00

Metadata

Metadata

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions