fix(core): parse cc provider subprocess errors into clean messages#44
Open
anhermon wants to merge 1 commit into
Open
fix(core): parse cc provider subprocess errors into clean messages#44anhermon wants to merge 1 commit into
anhermon wants to merge 1 commit into
Conversation
When the `claude` CLI returns a JSON response with `is_error: true`, the provider now detects this and returns a clean `HarnessError::Provider` message instead of silently treating the error text as a success response. - Extract `parse_json_response()` helper for testability - Refactor `run_subprocess()` to delegate to `parse_json_response()` - Add `is_error` check in `stream()` fallback path - Add unit tests for success, error, and missing-result cases Closes ANGA-573 Co-Authored-By: Paperclip <noreply@paperclip.ing> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
anhermon
commented
Apr 5, 2026
anhermon
left a comment
Owner
Author
There was a problem hiding this comment.
CTO Review — Approve
Clean fix. parse_json_response extraction is well-scoped, 3 focused tests cover success/error/missing-field. Clippy clean.
Minor: em dash in error prefix (cc provider —) — confirm consistency with rest of codebase. Consider extracting shared check_error_response helper to reduce duplication between parse_json_response and stream() fallback path.
No blocking issues. ✅
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.
Thinking Path
The
claudeCLI can return JSON withis_error: truewhen there's an account/model access error. The existing code blindly extracted theresultfield as success text, meaning error messages like "Your account does not have access..." were silently returned as if they were valid assistant responses.What Changed
parse_json_response()helper onClaudeCodeProvider— parses the JSON output fromclaude --output-format json, checksis_errorbefore extractingresult, and returns a cleanHarnessError::Provideron error responses.run_subprocess()to delegate JSON parsing toparse_json_response()instead of inline parsing.is_errorcheck instream()fallback path — the fallback that reads theresultfield from stream-json output now also checks for error responses before pushing a chunk.Verification
cargo test --workspace— all 82 tests passcargo clippy -- -D warnings— clean, no warningsRisks
parse_json_responsehelper is a pure function extracted from existing logic with an added guard clause. The stream fallback change mirrors the same pattern.Checklist
cargo test --workspacepassescargo clippy -- -D warningspassesCloses ANGA-573