fix(cli): surface nested provider error messages - #13062
Open
aaronlippold wants to merge 1 commit into
Open
Conversation
Gemini (and other providers') quota/RESOURCE_EXHAUSTED responses carry the real message double-nested in JSON that formatError did not unwrap, so users saw raw JSON or "Unknown error" instead of the actual cause. Extract the nested message (depth-capped) and fall back to the original text when none is found. Refs continuedev#13052 Authored by: Aaron Lippold<lippold@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR improves CLI error rendering by unwrapping provider error payloads where the real human-readable message is nested inside JSON (including Gemini-style double-nested envelopes), so users see the actual quota/cause text instead of raw JSON or “Unknown error”.
Changes:
- Add
extractNestedJsonMessageto parse and unwrap nested provider error messages with a bounded depth. - Apply nested-message extraction when formatting
Errorinstances informatError. - Extend
formatErrortests with Gemini-style nested JSON message vectors and direct helper coverage.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| extensions/cli/src/util/formatError.ts | Adds nested JSON message extraction and uses it when formatting Error objects. |
| extensions/cli/src/util/formatError.test.ts | Adds regression tests for nested Gemini-style error payload extraction and helper behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
| } | ||
|
|
||
| return message?.trim(); |
Comment on lines
56
to
60
| export function formatError(error: any): string { | ||
| if (error instanceof Error) { | ||
| return error.message; | ||
| return extractNestedJsonMessage(error.message) ?? error.message; | ||
| } | ||
|
|
Comment on lines
+239
to
+242
| it("returns undefined for plain non-JSON text", () => { | ||
| expect(extractNestedJsonMessage("socket hang up")).toBeUndefined(); | ||
| }); | ||
| }); |
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
Part 3 of 4 of #13052 (tracking issue with full root-cause analysis and the PR split plan).
Gemini (and other providers') quota/
RESOURCE_EXHAUSTEDresponses carry the real message double-nested in JSON thatformatErrordid not unwrap — users saw raw JSON or "Unknown error" instead of the actual cause (e.g. the quota that was exhausted and the retry delay). This extracts the nested message (depth-capped unwrap) and falls back to the original text when none is found.CLI counterpart to #13014, which fixes the same class of problem in the GUI layer.
AI Code Review
@continue-reviewChecklist
Screen recording or screenshot
N/A — terminal error-text formatting in
extensions/cli/src/util/formatError.ts. Before/after is captured in the test expectations: raw double-nested JSON in, human-readable provider message out.Tests
extensions/cli/src/util/formatError.test.tsextended (36 tests total in the file): nested Gemini quota payload extraction, double-nested JSON, depth-cap behavior on pathological nesting, non-JSON fallthrough, and the existing provider-error cases as regression cover.