fix: non-zero exit code when a workflow run ends failed or aborted#2959
Open
doquanghuy wants to merge 1 commit into
Open
fix: non-zero exit code when a workflow run ends failed or aborted#2959doquanghuy wants to merge 1 commit into
doquanghuy wants to merge 1 commit into
Conversation
workflow run and workflow resume printed Status: failed (or emitted the --json payload) and exited 0, so scripts and CI could not rely on the process exit code. Map terminal outcomes: failed|aborted -> 1, completed|paused -> 0, on both the text and --json paths. The previous exit-0-on-failed behavior was pinned by test_workflow_run_failing_yaml_without_project; the pin is updated to the new contract. Fixes github#2958
Contributor
Author
|
@mnriem when you have a moment, would appreciate a review — happy to adjust anything. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #2958.
workflow runandworkflow resumeended with exit code 0 even when the run finishedStatus: failed, so scripts/CI had to parse stdout to detect failure. This PR adds a single status→exit-code mapping (_run_outcome_exit_code:failed/aborted→ 1;completed/paused→ 0 — paused is a waiting state, not a failure) and applies it at the four epilogues (run/resume × text/--json). The--jsonpayload itself is unchanged — it still prints first; only the process exit code changes.Behavior change, flagged plainly: the old behavior was deliberately pinned by
tests/test_workflow_run_without_project.py::test_workflow_run_failing_yaml_without_project(exit_code == 0asserted on a failed run). That pin is updated to the new contract with an explanatory comment. Anyone scripting against exit-0-on-failed would be affected — the issue discusses the trade-off; happy to gate this behind a flag instead if you'd rather not change the default.Testing
uv sync && uv run pytest— full suite 3728 passedTestWorkflowRunExitCodes(3 CLI-level tests): failed→1 (text +--json), completed→0; the two failure-path tests are red against currentmain, green with the fix (verified both directions)uvx ruff check src/— cleanuv run specify --helpCliRunner)AI Disclosure
Code, tests, and this description were authored with AI assistance (Claude); verified by running the repo's test suite and ruff locally in both red (unfixed) and green (fixed) directions.