fix(server): a failed Claude text generation now shows the CLI's own error #12652
ClosedMnigos(GitHub profile, opens in a new tab)wants to merge 2 commits into
main fromrefs/pull/12652/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
- apps/server/src/textGeneration/ClaudeTextGeneration.ts lines 274 to 275Resolvedby Mnigos(GitHub profile, opens in a new tab)@@ -252,4 +265,5 @@252265 if (exitCode !== 0) {253266 const stderrDetail = stderr.trim();254267 const stdoutDetail = stdout.trim();255- const detail = stderrDetail.length > 0 ? stderrDetail : stdoutDetail;268+ const detail =269+ claudeFailureResult(stdoutDetail) ??
juliusmarminge added labelsmacroscope-review
- apps/server/src/textGeneration/ClaudeTextGeneration.ts line 85Resolvedby Mnigos(GitHub profile, opens in a new tab)@@ -70,3 +70,16 @@7070 Schema.fromJsonString(Schema.Union([ClaudeOutputEnvelope, Schema.Array(ClaudeOutputMessage)])),7171 );727273+const ClaudeFailureMessage = Schema.Struct({ result: Schema.String });74+const isClaudeFailureMessage = Schema.is(ClaudeFailureMessage);75+const decodeClaudeFailureOutput = Schema.decodeUnknownOption(Schema.fromJsonString(Schema.Unknown));76+77+const MAX_CLAUDE_FAILURE_RESULT_CHARS = 500;78+79+/** A failed `--output-format json` run still reports the reason on stdout,80+ while stderr may only hold notices from a wrapper around the binary. The81+ result can embed a whole upstream response, so it is capped for the toast. */82+function claudeFailureResult(stdout: string): string | undefined {83+ const output = Option.getOrUndefined(decodeClaudeFailureOutput(stdout));84+ const message = Array.isArray(output) ? output.findLast(isClaudeFailureMessage) : output;85+ const result = isClaudeFailureMessage(message) ? message.result.trim() : "";
Mnigos(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.


No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
30d403e8-8bce-484a-9857-541e486c6dff📥 Commits
Reviewing files that changed from the base of the PR and between c615ace24f3e8240752d51a1a0a2adf7a616fbe7 and 2c41b9c9a086a14c773186f134c1b419dd82acca.
📒 Files selected for processing (2)
apps/server/src/textGeneration/ClaudeTextGeneration.test.tsapps/server/src/textGeneration/ClaudeTextGeneration.ts🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.
📝 Walkthrough
Walkthrough#
Claude failure results longer than 500 characters are truncated with an ellipsis. Tests cover truncation and five stdout/stderr failure-output combinations.
Changes#
Claude failure handling
apps/server/src/textGeneration/ClaudeTextGeneration.ts,apps/server/src/textGeneration/ClaudeTextGeneration.test.tsclaudeFailureResulttruncates non-empty results longer than 500 characters. Tests verify the truncated detail and stdout/stderr fallback cases.Priority: ⬇️ Low
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Suggested reviewers:
t3dotgg🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment `@coderabbitai help` to get the list of available commands.