Repository navigation
fix(providers): keep Claude CLI API errors on the non-streaming path - #1706
pcbeingused33 wants to merge 2 commits into
Conversation
clark-cant
left a comment
There was a problem hiding this comment.
Summary: Extends the Claude CLI error-surfacing fix (stream path, #884) to the non-streaming Chat path: parseJSONArray and parseSingleJSONResult now honor is_error (which can be true with subtype success), and when stderr is empty Chat recovers the API error message from the result event on stdout.
Risk level: Low - 4 files, +89/-3, provider-internal, no API/DB/config surface, CI green (go, web, release-versioning).
Mandatory gates:
- Duplicate / prior implementation: clear - #884/#885 fixed the stream path (commit 91d79ce); this is the matching non-streaming follow-up; no open PR overlaps.
- Project standards: docs found (AGENTS.md, CONTRIBUTING.md) - base dev correct, conventional commit, tests included, Go conventions honored.
- Strategic necessity: clear value - surfaces the real API error (e.g. 529 overloaded) instead of exit status 1 (stderr: ), reducing support toil.
Findings:
- Critical: none.
- Important: none.
- Suggestion:
- cliResultError re-scans the output for the failed result event while parseJSONArray/parseSingleJSONResult already apply the same subtype==error || is_error predicate - the rule now lives in three places. Consider having the parsers surface the message (or share a helper) so it lives in one.
- Edge: an is_error result with empty result/error that exits 0 still falls through to the raw-text fallback in parseJSONResponse (returns the JSON blob as content with finish_reason stop). The zero-exit case is only fully covered when a message is present; a follow-up guard/test would close it.
- AGENTS.md asks for a Surface parity line on fixes; a one-liner (Surface parity: provider-internal, N/A) would keep the checklist honest. Cosmetic.
Verdict: Approve - no critical or important issues; the change mirrors the existing ChatStream handling and is well tested.
Posted by /ck:review-pr at 2026-11-29T01:08:26Z
|
Thanks for catching the zero-exit case. An empty This comment was drafted with Claude Code. |
clark-cant
left a comment
There was a problem hiding this comment.
Summary: Re-review of the follow-up commit 15d595b9 ("report empty Claude CLI result errors"). It closes the zero-exit gap flagged in the prior review: an is_error result event with an empty result/error now yields an explicit error on the non-streaming path, and parseJSONArray no longer falls back to assistant text once the result event has failed.
Risk level: Low - this commit touches 2 files (+55/-14), provider-internal, no API/DB/config surface, CI green (go, web, release-versioning).
Mandatory gates:
- Duplicate / prior implementation: clear - follow-up to #884/#885 (stream path, commit 91d79ce); no overlapping open PR.
- Project standards: docs found (AGENTS.md, CONTRIBUTING.md) - base dev correct, conventional commit, tests included, Go conventions honored.
- Strategic necessity: clear - surfaces the real API error instead of exit status 1 / the raw JSON blob, reducing support toil.
Findings:
- Critical: none.
- Important: none.
- Suggestion:
parseJSONArraynow discards accumulated assistant text whenever the result event isis_error(thefinishReason != "error"guard), so a mid-stream API error that arrives after a partial answer returnsresult error (no message)and drops that partial text. Consider returning the partial text withFinishReason=error, or including it in the error, so callers do not silently lose content.- The
subtype == "error" || is_errorpredicate now lives in four places (parseJSONArray,parseSingleJSONResult,cliResultError,ChatStream) - a shared helper would keep the rule in one spot. (Carried over from the prior review.) - AGENTS.md asks for a Surface parity line on fixes; a one-liner (Surface parity: provider-internal, N/A) would keep the checklist honest. Cosmetic.
Verdict: Approve - the follow-up correctly closes the zero-exit empty-message gap with regression tests for object, array, and array-with-assistant shapes; no critical or important issues.
Posted by /ck:review-pr at 2026-11-29T10:09:22Z
Summary
Without streaming, the Claude CLI provider loses API errors. A failed turn that exits non-zero returns
claude-cli: exit status 1 (stderr: )with no cause, and a result flaggedis_errorwithsubtype: "success"that exits zero is returned as a normal answer (finish_reason: "stop").Root cause: the CLI reports API errors in the
resultevent on stdout.ChatStreamalready checksis_errorand recovers the message, butChatreads only stderr on failure, andparseJSONArray/parseSingleJSONResultcheck onlysubtype == "error".Fix: both parsers also honor
is_error, and when stderr is emptyChatadds the message from the failed result event to the returned error, preferringerroroverresultasChatStreamdoes. A non-empty stderr is reported as before.Type
Target Branch
devChecklist
go build ./...passesgo build -tags sqliteonly ./...passesgo vetpasses (./internal/providers)go test -race ./internal/providers/...(providers packages only)Test Plan
New tests cover an
is_errorresult in object and array form, and runChatagainst a fake CLI script that prints a failed result and exits 1. They fail without the change and pass with it. The CLI output in the tests is simulated; no real Claude CLI call was made.🤖 Generated with Claude Code