Handle stringified forwarded chatError - #333363
Open
boygeniusnr1 wants to merge 2 commits into
Open
Conversation
…\n\nParse JSON when _meta.chatError is a string so friendly forwarded messages render instead of falling back to generic errors. Add focused unit test.\n\nCo-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Parses stringified forwarded chat errors so core can display host-provided friendly messages.
Changes:
- Parse JSON-stringified
_meta.chatErrorpayloads. - Add focused coverage for successful parsing.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
chatErrorMessages.ts |
Parses and validates stringified chat errors. |
chatErrorMessages.stringified.test.ts |
Tests successful parsing and formatting. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+19
to
+36
| test('parses stringified forwarded chatError', () => { | ||
| const payload = JSON.stringify({ | ||
| fetchError: { | ||
| type: ChatFetchResponseType.RateLimited, | ||
| retryAfter: 60, | ||
| capiError: { code: 'user_global_rate_limited', message: 'slow down' }, | ||
| }, | ||
| copilotPlan: 'free', | ||
| }); | ||
|
|
||
| const details = getChatErrorDetailsFromMeta(errorInfo({ chatError: payload })); | ||
| assert.deepStrictEqual(details, { | ||
| code: ChatFetchResponseType.RateLimited, | ||
| message: 'You\'ve hit your session rate limit. Please upgrade your plan or wait 60 seconds for your limit to reset. [Learn More](https://aka.ms/github-copilot-rate-limit-error)', | ||
| level: ChatErrorLevel.Info, | ||
| isRateLimited: true, | ||
| }); | ||
| }); |
Author
|
@microsoft-github-policy-service agree [company="{your company}"] |
… undefined (safe fallback)\n\nAdd unit test verifying invalid JSON in _meta.chatError is handled without throwing, preserving generic error fallback.\n\nCo-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Author
|
@microsoft-github-policy-service agree |
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.
Problem: hosts sometimes forward _meta.chatError as a JSON string; core ignored it and showed a generic error message.\n\nSolution: parse stringified _meta.chatError when present, validate the parsed shape, and render friendly messages forwarded from the host.\n\nFiles changed:\n- Modified: src/vs/workbench/contrib/chat/common/chatErrorMessages.ts\n- Added: src/vs/workbench/contrib/chat/test/common/chatErrorMessages.stringified.test.ts\n\nNotes: Added a focused unit test. Local focused validation passed in the worktree; repo-wide test runs may require Node v24.18+ and the native build toolchain. Please run CI and report any failures.\nShould fix at least some of #253136