Skip to content

[Code Quality] Fix context.Background() in pkg/parser/remote_workflow_spec.go to honour compile cancellation #48469

Description

@github-actions

Description

pkg/parser/remote_workflow_spec.go hard-codes context.Background() for three network calls (downloadFileFromGitHub / resolveRefToSHA at lines 91, 93, 156), even though these calls execute during the compilation pipeline where the caller holds a live, cancellable context. When a user presses Ctrl+C, compilation continues at these network steps until they time out.

A TODO comment at line 71 already acknowledges this gap.

Suggested Changes

  • Pass a context.Context parameter through downloadFileFromGitHub and resolveRefToSHA
  • Replace context.Background() at lines 91, 93, and 156 with the propagated context
  • Update all callers that invoke these functions to pass their existing context

Files Affected

  • pkg/parser/remote_workflow_spec.go (lines 71, 91, 93, 156)
  • Callers of downloadFileFromGitHub / resolveRefToSHA in the parser package

Success Criteria

  • No context.Background() calls remain inside remote_workflow_spec.go (except legitimate entry-point anchors)
  • Cancelling a compile via Ctrl+C also cancels in-flight remote workflow fetches
  • All existing tests pass

Source

Extracted from [repository-quality] Repository Quality Improvement Report discussion #48389

Priority

High — remote fetches during compilation are fully uncancellable; a TODO already marks this as known debt

🔍 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:17 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