Skip to content

Fix context cancel lifecycle violations in workflow + MCP inspect paths#35811

Merged
pelikhan merged 4 commits into
mainfrom
copilot/lint-monster-fix-cancel-function-violations
May 29, 2026
Merged

Fix context cancel lifecycle violations in workflow + MCP inspect paths#35811
pelikhan merged 4 commits into
mainfrom
copilot/lint-monster-fix-cancel-function-violations

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 29, 2026

LintMonster flagged 6 contextcancelnotdeferred findings where cancel funcs from context.WithTimeout were not deferred immediately after creation. This updates the affected call sites to follow the required context lifecycle pattern without changing behavior.

  • Workflow resolver: annotated tag peel timeout

    • Updated /pkg/workflow/action_resolver.go to defer peelCancel() immediately after context.WithTimeout(...) in the tag-peeling loop.
  • Safe outputs: remote action YAML fetch timeout

    • Updated /pkg/workflow/safe_outputs_actions.go to defer cancel() immediately after timeout context creation in fetchRemoteActionYAML.
  • CLI MCP inspect: operation-scoped contexts

    • Updated /pkg/cli/mcp_inspect_mcp.go at all reported ListTools / ListResources timeout contexts (stdio + HTTP paths) to defer cancellation immediately after context creation.

Example pattern applied:

opCtx, cancel := context.WithTimeout(ctx, MCPOperationTimeout)
defer cancel()

result, err := session.ListTools(opCtx, &mcp.ListToolsParams{})

Copilot AI and others added 2 commits May 29, 2026 23:08
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix context cancel function defer violations Fix context cancel lifecycle violations in workflow + MCP inspect paths May 29, 2026
Copilot AI requested a review from gh-aw-bot May 29, 2026 23:16
@pelikhan
Copy link
Copy Markdown
Collaborator

@copilot the explicit cancel too

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 29, 2026

@copilot the explicit cancel too

Addressed in 6c07037. I restored explicit cancel() calls at the affected sites while keeping immediate defer cancel() for lint compliance and panic-safe cleanup.

Copilot AI requested a review from pelikhan May 29, 2026 23:35
@pelikhan pelikhan marked this pull request as ready for review May 29, 2026 23:46
Copilot AI review requested due to automatic review settings May 29, 2026 23:46
@pelikhan pelikhan merged commit 62ff2f2 into main May 29, 2026
1 check failed
@pelikhan pelikhan deleted the copilot/lint-monster-fix-cancel-function-violations branch May 29, 2026 23:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[lint-monster] fix: resolve context cancel function defer violations (6 findings)

4 participants