Skip to content

Fix JSON extraction to handle escape sequences during parsing phase#832

Closed
Copilot wants to merge 3 commits into
error-handling-formsfrom
copilot/sub-pr-830-again
Closed

Fix JSON extraction to handle escape sequences during parsing phase#832
Copilot wants to merge 3 commits into
error-handling-formsfrom
copilot/sub-pr-830-again

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 16, 2026

Addresses feedback on extractServerErrorFromMessage where 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 inString and escapeNext state to only count braces outside quoted strings, preventing mismatches when braces appear in message content

  • Move unescaping after extraction: Handle doubly-escaped JSON ({\"type\":...}) after finding valid JSON substring, not as preprocessing

  • Comprehensive test coverage: Added test suite covering normal/doubly-escaped quotes, nested objects, and braces in string literals

Example error message that now parses correctly:

// Braces in string content no longer interfere
'Error: {"type":"ValidationError","message":"Required fields: {name}, {email}"}'
// → Extracts: "Required fields: {name}, {email}"

// Multiple JSON-like structures - finds the valid one
'First {"invalid":} then {"type":"RealError","message":"Real message"}'  
// → Extracts: "Real message"

💡 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.

Copilot AI and others added 2 commits February 16, 2026 07:45
…parsing phase

Co-authored-by: dmitrymalk <2931932+dmitrymalk@users.noreply.github.com>
…tching logic

Co-authored-by: dmitrymalk <2931932+dmitrymalk@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 16, 2026

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:

  • artifacts.cibseven.org
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm ci (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npx vitest run src/__tests__/utils/error.test.js (dns block)

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
Copilot AI requested a review from dmitrymalk February 16, 2026 07:51
@dmitrymalk dmitrymalk closed this Feb 16, 2026
@dmitrymalk dmitrymalk deleted the copilot/sub-pr-830-again branch February 16, 2026 09:19
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