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.go → CompileWorkflows), 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:
- Repo validation queries target the correct GHE endpoint
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
Generated by 📋 Plan Command · ◷
Comment /plan to run again
Problem
The
gh aw addandgh aw auditcommands callgetHostFromOriginRemote()to auto-detect when the git remote is a GitHub Enterprise Server host, then callworkflow.SetDefaultGHHost(detectedHost)so that subsequentgh apicalls target the correct GHE instance.The
gh aw compilecommand does not do this. When a user on a GHE instance runsgh aw compile --validatewithout settingGH_HOST, repo validation calls (checkRepositoryHasIssuesUncached,checkRepositoryHasDiscussionsUncached) use theghCLI's default configuration, which may silently target the wrong host.Additionally, without
SetDefaultGHHostbeing called, theSkipHardcodedFallbackcheck inPinContext()(even after the companion fix to checkgetDefaultGHHost()) won't activate for the compile command whenGH_HOSTenv is unset.Related issue: #39792
Fix
In the compile command's startup path (e.g.,
pkg/cli/compile_orchestrator.go→CompileWorkflows), add GHE host auto-detection identical to whatadd_interactive_orchestrator.godoes:This ensures:
SkipHardcodedFallbackis set correctly viaPinContext()(after the companion fix)Files to modify
pkg/cli/compile_orchestrator.go— add GHE host auto-detection at compile startuppkg/cli/compile_orchestrator_stability_test.goor a new test file — add test verifying thatSetDefaultGHHostis called when origin remote is a GHE hostAcceptance criteria
CompileWorkflowscallsworkflow.SetDefaultGHHostwith the detected GHE host when the git remote is notgithub.comandGH_HOSTenv is unsetCompileWorkflowsdoes NOT callworkflow.SetDefaultGHHostwhenGH_HOSTis already set in envgithub.com(public GitHub)make agent-report-progress)