Skip to content

[Code Quality] refactor: migrate remaining RunGHWithHost call sites to RunGHContextWithHost (89% still legacy) #49536

Description

@github-actions

Description

A prior effort (#48436/#48488) threaded context.Context through the base ExecGH/RunGH/RunGHCombined wrappers in pkg/workflow/github_cli.go, but RunGHWithHost was left with its non-context signature alongside RunGHContextWithHost. Adoption of the context-aware variant remains very low: only 1 of 8 call sites in pkg/cli use RunGHContextWithHost, meaning cross-host gh operations (against GHES / data-residency hosts) still cannot be cancelled or bounded by a caller timeout.

Current State (verified)

$ grep -rn "workflow\.RunGHWithHost(" pkg/cli --include='*.go' | grep -v _test.go
pkg/cli/pr_command.go:771
pkg/cli/pr_command.go:793
pkg/cli/add_package_manifest.go:938
pkg/cli/add_package_manifest.go:990
pkg/cli/outcome_eval.go:261
pkg/cli/outcome_eval.go:286
pkg/cli/outcome_eval.go:307

7 legacy call sites vs 1 context-aware call site.

Suggested Changes

  • Replace each workflow.RunGHWithHost(...) call above with workflow.RunGHContextWithHost(ctx, ...), threading ctx from the enclosing Cobra command's cmd.Context() or an existing ctx parameter down through intervening helper functions.
  • Do not change spinner messages, error handling, or output parsing — this is a signature/threading-only change.
  • Once all production call sites are migrated, consider marking RunGHWithHost in pkg/workflow/github_cli.go with a // Deprecated: comment pointing to RunGHContextWithHost.

Files Affected

  • pkg/cli/pr_command.go (lines 771, 793)
  • pkg/cli/add_package_manifest.go (lines 938, 990)
  • pkg/cli/outcome_eval.go (lines 261, 286, 307)
  • pkg/workflow/github_cli.go (optional deprecation comment on RunGHWithHost)

Success Criteria

  • grep -rn "workflow\.RunGHWithHost(" pkg/cli --include='*.go' | grep -v _test.go returns zero results
  • make fmt and make agent-report-progress-no-test pass
  • Existing tests in pkg/cli/pr_command_test.go, pkg/cli/add_package_manifest_test.go, and pkg/cli/outcome_eval_test.go pass unchanged

Source

Extracted from Repository Quality Improvement Report - GH CLI Wrapper Context Propagation Gap discussion #49349 (Task 1/4, focused to the highest-gap subset not covered by prior closed work #48436/#48488).

Priority

Medium - improves cancellability of cross-host GitHub operations but not blocking.

🔍 Task mining by Discussion Task Miner - Code Quality Improvement Agent · auto · 57 AIC · ⌖ 7.48 AIC · ⊞ 10.2K ·

  • expires on Aug 1, 2026, 11:39 PM UTC-08:00

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions