Description
Two secondary context.Background() leakage sites identified in the context cancellation audit (discussion #48389):
-
pkg/cli/logs_orchestrator_filters.go:167 — fetchJobStatusesForProcessedRun(context.Background(), ...) is called inside buildRunsModel; the enclosing log-download commands carry a live context. Ctrl+C cannot cancel job-status fetches.
-
pkg/cli/update_extension_check.go:49 — upgradeExtensionIfOutdated has no context parameter, but its only caller (runUpgradeCommand:245) holds opts.ctx from cobra. The GitHub API call for the latest release is fully uncancellable.
Suggested Changes
logs_orchestrator_filters.go
- Propagate context from the caller into
buildRunsModel → fetchJobStatusesForProcessedRun
- Replace
context.Background() at line 167 with the passed-in context
update_extension_check.go
- Add
ctx context.Context parameter to upgradeExtensionIfOutdated
- Update the call site in
runUpgradeCommand to pass opts.ctx
- Use the context for the GitHub API release-check call
Files Affected
pkg/cli/logs_orchestrator_filters.go (line 167)
pkg/cli/update_extension_check.go (line 49, 245)
Success Criteria
- Both functions accept and honour a
context.Context parameter
- Ctrl+C during log downloads and extension checks propagates cancellation correctly
- All existing tests pass
Source
Extracted from [repository-quality] context.Background() Call-Chain Leakage discussion #48389
Priority
Medium — improves cancellation UX for log-download and upgrade commands
🔍 Task mining by Discussion Task Miner - Code Quality Improvement Agent · sonnet46 · 84.8 AIC · ⌖ 5.53 AIC · ⊞ 7.2K · ◷
Description
Two secondary
context.Background()leakage sites identified in the context cancellation audit (discussion #48389):pkg/cli/logs_orchestrator_filters.go:167—fetchJobStatusesForProcessedRun(context.Background(), ...)is called insidebuildRunsModel; the enclosing log-download commands carry a live context. Ctrl+C cannot cancel job-status fetches.pkg/cli/update_extension_check.go:49—upgradeExtensionIfOutdatedhas no context parameter, but its only caller (runUpgradeCommand:245) holdsopts.ctxfrom cobra. The GitHub API call for the latest release is fully uncancellable.Suggested Changes
logs_orchestrator_filters.go
buildRunsModel→fetchJobStatusesForProcessedRuncontext.Background()at line 167 with the passed-in contextupdate_extension_check.go
ctx context.Contextparameter toupgradeExtensionIfOutdatedrunUpgradeCommandto passopts.ctxFiles Affected
pkg/cli/logs_orchestrator_filters.go(line 167)pkg/cli/update_extension_check.go(line 49, 245)Success Criteria
context.ContextparameterSource
Extracted from [repository-quality] context.Background() Call-Chain Leakage discussion #48389
Priority
Medium — improves cancellation UX for log-download and upgrade commands