Skip to content

Handle stringified forwarded chatError - #333363

Open
boygeniusnr1 wants to merge 2 commits into
microsoft:mainfrom
boygeniusnr1:boygeniusnr1-fix-meta-sorry-request-failed
Open

Handle stringified forwarded chatError#333363
boygeniusnr1 wants to merge 2 commits into
microsoft:mainfrom
boygeniusnr1:boygeniusnr1-fix-meta-sorry-request-failed

Conversation

@boygeniusnr1

@boygeniusnr1 boygeniusnr1 commented Aug 30, 2026

Copy link
Copy Markdown

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

…\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>
Copilot AI balanced review requested due to automatic review settings August 30, 2026 00:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Parses stringified forwarded chat errors so core can display host-provided friendly messages.

Changes:

  • Parse JSON-stringified _meta.chatError payloads.
  • 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,
});
});
@boygeniusnr1

Copy link
Copy Markdown
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>
@boygeniusnr1

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants