fix: capture stderr in ProcessError for better debugging (#641)#658
Open
MaxwellCalkin wants to merge 1 commit intoanthropics:mainfrom
Open
fix: capture stderr in ProcessError for better debugging (#641)#658MaxwellCalkin wants to merge 1 commit intoanthropics:mainfrom
MaxwellCalkin wants to merge 1 commit intoanthropics:mainfrom
Conversation
) Previously, stderr was only piped when the user provided a callback or enabled debug mode. When the CLI process exited with an error, ProcessError was raised with the generic message "Check stderr output for details" instead of the actual error text. This change: - Always pipes stderr from the subprocess - Buffers all stderr lines in _stderr_buffer alongside existing callbacks - Uses the captured stderr content in ProcessError when the process fails - Resets the buffer on close() to prevent memory leaks Fixes anthropics#641 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
amazing, let's merge this asap |
|
Is this the same as #529? |
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.
Summary
Fixes #641 —
ProcessErrornow includes the actual CLI stderr output instead of a generic placeholder message.Problem: When the CLI subprocess exits with a non-zero exit code,
ProcessErrorwas raised withstderr="Check stderr output for details"— a hardcoded string that provides no useful debugging information. Worse, stderr was only piped at all when the user explicitly provided astderrcallback or enabled debug mode, so in the common case the real error output was lost entirely.Root cause in
subprocess_cli.py:_handle_stderr()for callbacks but never retainedProcessErroralways used a hardcoded placeholder stringFix:
self._stderr_buffer(in addition to invoking existing user callbacks / debug output)ProcessError, so callers see the real CLI errorclose()to prevent memory leaksBefore
After
Test plan
ruff checkpasses — no lint issuesmypypasses — no type errorsProcessError.stderrcontains the real error message🤖 Generated with Claude Code