Fix JSON extraction to handle escape sequences during parsing phase#832
Closed
Copilot wants to merge 3 commits into
Closed
Fix JSON extraction to handle escape sequences during parsing phase#832Copilot wants to merge 3 commits into
Copilot wants to merge 3 commits into
Conversation
…parsing phase Co-authored-by: dmitrymalk <2931932+dmitrymalk@users.noreply.github.com>
…tching logic Co-authored-by: dmitrymalk <2931932+dmitrymalk@users.noreply.github.com>
Contributor
Author
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Copilot
AI
changed the title
[WIP] Update error handling improvements in embedded forms
Fix JSON extraction to handle escape sequences during parsing phase
Feb 16, 2026
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.
Addresses feedback on
extractServerErrorFromMessagewhere preprocessing unescaped quotes before brace matching could cause incorrect parsing when error messages contain legitimate\"sequences or braces inside quoted strings.Changes
Find all brace positions and try each: Instead of
lastIndexOf('{')which can find braces inside string literals, scan all{positions and attempt parsing from each (last to first)Track string context during brace matching: Maintain
inStringandescapeNextstate to only count braces outside quoted strings, preventing mismatches when braces appear in message contentMove unescaping after extraction: Handle doubly-escaped JSON (
{\"type\":...}) after finding valid JSON substring, not as preprocessingComprehensive test coverage: Added test suite covering normal/doubly-escaped quotes, nested objects, and braces in string literals
Example error message that now parses correctly:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.