Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix: improve JSON parsing to handle nested markdown code blocks#289

Merged
breaking-brake merged 1 commit intomainbreaking-brake/cc-wf-studio:mainfrom
fix/parse-nested-markdown-code-blocksbreaking-brake/cc-wf-studio:fix/parse-nested-markdown-code-blocksCopy head branch name to clipboard
Dec 17, 2025
Merged

fix: improve JSON parsing to handle nested markdown code blocks#289
breaking-brake merged 1 commit intomainbreaking-brake/cc-wf-studio:mainfrom
fix/parse-nested-markdown-code-blocksbreaking-brake/cc-wf-studio:fix/parse-nested-markdown-code-blocksCopy head branch name to clipboard

Conversation

@breaking-brake
Copy link
Copy Markdown
Owner

Problem

When AI Workflow Refinement returns a response wrapped in ```json...``` and the JSON content itself contains ``` (code blocks), a PARSE_ERROR occurs.

Current Behavior

  1. AI returns ```json { "status": "clarification", "message": "...```\n...```..." } ```
  2. ❌ Regex terminates at the first ``` inside the JSON
  3. JSON.parse() fails with PARSE_ERROR

Expected Behavior

  1. AI returns the same format
  2. ✅ Only outer markers are removed
  3. ✅ Parse succeeds, clarification message displays correctly

Solution

Changed parseClaudeCodeOutput() from regex-based extraction to position-based extraction.

Changes

File: src/extension/services/claude-code-service.ts

  • If output starts with ```json and ends with ```, remove only outer markers
  • Inner code blocks are not affected
if (trimmed.startsWith('```json') && trimmed.endsWith('```')) {
  const jsonContent = trimmed
    .slice(7)  // Remove ```json
    .slice(0, -3)  // Remove trailing ```
    .trim();
  return JSON.parse(jsonContent);
}

Impact

  • AI Refinement clarification responses are now parsed correctly
  • No breaking changes to existing behavior

Testing

  • Manual E2E testing with mock nested code block response
  • Code quality checks passed (format, lint, check, build)

🤖 Generated with Claude Code

- Changed parseClaudeCodeOutput() to use position-based extraction
- Removes only outer ```json...``` markers instead of regex matching
- Fixes PARSE_ERROR when AI response contains code blocks in message

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@breaking-brake breaking-brake merged commit d0ca208 into main Dec 17, 2025
3 checks passed
@breaking-brake breaking-brake deleted the fix/parse-nested-markdown-code-blocks branch December 17, 2025 09:37
@breaking-brake breaking-brake mentioned this pull request Dec 17, 2025
github-actions Bot added a commit that referenced this pull request Dec 17, 2025
## [3.8.1](v3.8.0...v3.8.1) (2025-12-17)

### Bug Fixes

* dialog positioning broken by NodePalette transform ([#290](#290)) ([b1adb8f](b1adb8f))
* improve JSON parsing to handle nested markdown code blocks ([#289](#289)) ([d0ca208](d0ca208))
@github-actions
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 3.8.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.