[repository-quality] Repository Quality Improvement Report — Remote Fetch API Context Gap #42975
Closed
Replies: 1 comment
-
|
This discussion has been marked as outdated by Repository Quality Improvement Agent. A newer discussion is available at Discussion #43206. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
🎯 Repository Quality Improvement Report — Remote Fetch API Context Gap
Analysis Date: 2026-07-02
Focus Area: Remote Fetch API Context Gap — Public
parserfunctions strip caller contextStrategy Type: Custom
Custom Area: Yes — caller context is silently discarded by 8 public wrappers in
pkg/parser/remote_fetch.goExecutive Summary
pkg/parser/remote_fetch.goexposes 8 public functions with nocontext.Contextparameter. All 8 delegate to private implementations that do accept context, but 7 auth-fallback sites hard-codecontext.Background()instead of threading the caller's context.Nine callers in
pkg/cli/already hold a cobracmd.Context()but cannot pass it — so Ctrl-C does not cancel in-flight HTTP requests. The fix is to addctx context.Contextto the 8 public APIs, propagate through the private chain, replace the 7context.Background()fallback sites, update CLI callers, and add a linter to prevent regression.Full Analysis
Public APIs with no context (pkg/parser/remote_fetch.go)
context.Background() hard-coded in fallback paths
CLI callers that cannot propagate context
Metrics:
🤖 Tasks for Copilot Agent
NOTE TO PLANNER AGENT: Split the following tasks into individual work items.
Task 1: Add
context.Contextto 8 public parser APIsPriority: High | Effort: Medium
Code Region:
pkg/parser/remote_fetch.goAdd
ctx context.Contextas the first parameter toDownloadFileFromGitHub,DownloadFileFromGitHubForHost,ResolveRefToSHAForHost,ListWorkflowFiles,ListWorkflowFilesForHost,ListDirAllFilesForHost,ListDirAllFilesRecursivelyForHost,ListDirSubdirsForHost. Thread ctx into private implementations (downloadFileFromGitHubWithDepth,listWorkflowFilesForHost, etc.) and replace the 7context.Background()fallback sites with the incoming ctx.Acceptance Criteria:
ctx context.Contextas first paramcontext.Background()fallback sites replaced with caller ctxgo build ./...andgo test ./pkg/parser/...passTask 2: Update CLI callers to pass
cmd.Context()Priority: High | Effort: Medium
Code Region:
pkg/cli/dispatch.go,pkg/cli/includes.go,pkg/cli/resources.go,pkg/cli/list_workflows_command.go,pkg/cli/add_package_manifest.goAfter Task 1, update all 9 call sites in pkg/cli/ to pass the cobra command context. Update
fileDownloadFntype indispatch.goto includectx context.Contextas first param. Thread ctx from cobra RunE handlers into helper functions.Acceptance Criteria:
fileDownloadFntype updated in dispatch.gogo build ./...andgo test ./pkg/cli/...passTask 3: Fix remaining context.Background() in CLI helpers
Priority: Medium | Effort: Small
Code Region:
pkg/cli/copilot_agents.go,pkg/cli/resources.go,pkg/cli/includes.gobuildAgenticWorkflowsSkillContent()(copilot_agents.go:222) callslistAgenticWorkflowsMarkdownFiles(context.Background()).resources.go:82andincludes.go:140callgetRepoDefaultBranch(context.Background(), ...). Thread the cobra context from the upstream RunE callers into these helpers.Acceptance Criteria:
buildAgenticWorkflowsSkillContentaccepts and uses ctxresources.go:82andincludes.go:140use caller ctx forgetRepoDefaultBranchgo build ./...andgo test ./pkg/cli/...passTask 4: Add
httpbgctxlinter to flaghttp.NewRequestWithContext(context.Background(), ...)Priority: Medium | Effort: Small
Code Region:
pkg/linters/Create
pkg/linters/httpbgctx/analyzer that flagshttp.NewRequestWithContext(context.Background(), ...)in non-test production code. Register inpkg/linters/linters.goandspec_test.go. Add testdata golden file.Acceptance Criteria:
📈 Success Metrics
Next Steps
References: §28593277510
Beta Was this translation helpful? Give feedback.
All reactions