fix(workflows): route run/resume errors to stderr under --json#3352
Open
jawwad-ali wants to merge 1 commit into
Open
fix(workflows): route run/resume errors to stderr under --json#3352jawwad-ali wants to merge 1 commit into
jawwad-ali wants to merge 1 commit into
Conversation
workflow run/resume --json is contracted to emit a single JSON object on stdout, but every error path (workflow-not-found, invalid workflow, validation failure, execute/resume failure, and the shared _parse_input_values invalid-input error) used console.print, landing the human error text on stdout and corrupting the machine-readable stream. Route those messages through err_console when --json is set (a no-op for normal text mode), mirroring the stderr-only error routing already used by 'specify bundle' (_fail) and err_console elsewhere in this module. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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
specify workflow run/resume --jsonis contracted to emit a single JSON object on stdout (the module already goes to great lengths for this — see_emit_workflow_jsonand_stdout_to_stderr_when, whichdup2-redirects step output to stderr during execution). But the command's own error paths useconsole.print, which writes to stdout even under--json:So a not-found / invalid / validation-failed / failed run — and the shared
_parse_input_valuesinvalid-input error — all corrupt the JSON stream a caller is trying to parse.Fix
Route those error messages through
err_consolewhen--jsonis set (a no-op in normal text mode, where they stay on the regular console). This mirrors the stderr-only error routing already used byspecify bundle(_fail) and byerr_consoleelsewhere in this same module. Covers bothworkflow runandworkflow resumeplus the shared input parser.Testing
New
TestWorkflowRunJsonErrorStream(CliRunner separates stdout/stderr in this repo's Click):--json:"validation failed"is not on stdout and is on stderr;--inputunder--json:"Invalid input format"is not on stdout and is on stderr.Both fail-before / pass-after (verified by source-stash).
uvx ruff checkclean.AI Disclosure
Found and fixed with Claude Code (Claude Fable 5) under my direction. AI spotted that the error paths bypassed the module's own stdout-cleanliness machinery; I confirmed the stream corruption, verified fail-before/pass-after, and reviewed the diff.