Skip to content

fix(cli): surface nested provider error messages - #13062

Open
aaronlippold wants to merge 1 commit into
continuedev:mainfrom
aaronlippold:fix/cli-gemini-error-surfacing
Open

fix(cli): surface nested provider error messages#13062
aaronlippold wants to merge 1 commit into
continuedev:mainfrom
aaronlippold:fix/cli-gemini-error-surfacing

Conversation

@aaronlippold

Copy link
Copy Markdown
Contributor

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_EXHAUSTED responses carry the real message double-nested in JSON that formatError did 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

  • Team members only: AI review runs automatically when PR is opened or marked ready for review
  • Team members can also trigger a review by commenting @continue-review

Checklist

  • I've read the contributing guide
  • The relevant docs, if any, have been updated or created — error formatting is internal behavior; no docs describe it
  • The relevant tests, if any, have been updated or created

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.ts extended (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.

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>
Copilot AI review requested due to automatic review settings July 29, 2026 15:55
@aaronlippold
aaronlippold requested a review from a team as a code owner July 29, 2026 15:55
@aaronlippold
aaronlippold requested review from sestinj and removed request for a team July 29, 2026 15:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 extractNestedJsonMessage to parse and unwrap nested provider error messages with a bounded depth.
  • Apply nested-message extraction when formatting Error instances in formatError.
  • Extend formatError tests 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();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants