Skip to content

run cancel: preserve API error message on non-completed 409 responses - #15103

Closed
alok-108 wants to merge 1 commit into
cli:trunkfrom
alok-108:fix/run-cancel-409-error
Closed

alok-108 wants to merge 1 commit into
cli:trunkfrom
alok-108:fix/run-cancel-409-error

Conversation

@alok-108

Copy link
Copy Markdown

Fixes #15053

Summary

Previously, gh run cancel treated every HTTP 409 Conflict response from POST /repos/{owner}/{repo}/actions/runs/{run_id}/cancel as "Cannot cancel a workflow run that is completed", hiding the actual API error message for non-completed runs (such as queued runs or other conflict states).

Changes

  • pkg/cmd/run/cancel/cancel.go: Only replace the HTTP 409 error with "Cannot cancel a workflow run that is completed" when run.Status == shared.Completed; otherwise, return the original api.HTTPError.
  • pkg/cmd/run/cancel/cancel_test.go: Added a unit test case verifying that a 409 response for a non-completed (queued) workflow run preserves the API error message.

Verification

  • go test -v ./pkg/cmd/run/cancel/...

@alok-108
alok-108 requested a review from a team as a code owner November 19, 2026 07:19
@alok-108
alok-108 requested review from tidy-dev and a balanced review from Copilot November 19, 2026 07:19
@github-actions github-actions Bot added external pull request originating outside of the CLI core team needs-triage needs to be reviewed ready-for-review and removed needs-triage needs to be reviewed labels Nov 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your pull request! While it doesn't meet all of our standard requirements, it appears to be a small, focused contribution and has been routed to the team for review.

Note: We still encourage linking to an issue with the help wanted label when possible, as it helps us prioritize and track contributions.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are recorded for the workflow cancellation error-handling change.

No open issues 🎉

What changed in this PR

Updates gh run cancel error handling to address #15053, preserving the API’s explanation when a non-completed workflow run cannot be canceled.

Changes:

  • Limits the completed-run error message to HTTP 409 responses for runs whose status is completed.
  • Adds a regression test verifying that queued runs retain the original API conflict message.
File Description
pkg/​cmd/​run/​cancel/​cancel.go Checks run status before replacing the HTTP 409 error.
pkg/​cmd/​run/​cancel/​cancel_test.go Tests preservation of the API error for a queued run.

Review effort: Balanced

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

Labels

external pull request originating outside of the CLI core team ready-for-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gh run cancel reports "Cannot cancel a workflow run that is completed" for any HTTP 409, hiding the real API error

3 participants