Skip to content

[Code Quality] Fix context.Background() in logs_orchestrator_filters.go and update_extension_check.go #48470

Description

@github-actions

Description

Two secondary context.Background() leakage sites identified in the context cancellation audit (discussion #48389):

  1. pkg/cli/logs_orchestrator_filters.go:167fetchJobStatusesForProcessedRun(context.Background(), ...) is called inside buildRunsModel; the enclosing log-download commands carry a live context. Ctrl+C cannot cancel job-status fetches.

  2. pkg/cli/update_extension_check.go:49upgradeExtensionIfOutdated 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 buildRunsModelfetchJobStatusesForProcessedRun
  • 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 ·

  • expires on Jul 28, 2026, 5:18 PM UTC-08:00

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions