-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Title: [Bug] JSON Parse Error (13310) in Claude Code Action when commit messages contain Markdown links
Description
anthropics/claude-code-action@v1 throws a SyntaxError: JSON Parse error when processing Pull Requests where commit messages contain Markdown link syntax (e.g., [text](url)).
Error Logs
SDK execution error: 13310
SyntaxError: JSON Parse error: Unable to parse JSON string
at readMessages (/home/runner/_work/_actions/anthropics/claude-code-action/v1/base-action/node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs:13315:32)
Root Cause Analysis
The SDK fails to properly escape characters used in Markdown link syntax ([], ()) when serializing CLI configuration or environment data (mcp-config) into the JSONL stream.
Specifically, when Claude Code automatically generates or reads a commit message containing:
🤖 Generated with [Claude Code](https://claude.ai/claude-code)
The internal JSON stringification seems to produce an invalid JSON line, causing the readline interface in the SDK to fail during parsing.
Steps to Reproduce (Verification)
- Scenario A (Success): PR with a simple commit message (e.g., "fix: update logic"). ✅ Works
- Scenario B (Failure): PR with a Markdown link in the commit message (e.g., "refactor: use [Claude Code](https://www.google.com/search?q=url)"). ❌ Fails with Error 13310
- Recovery: After amending the commit message to remove the
[]()characters, the action runs successfully. ✅ Works
Suggested Fix
The SDK's message-passing layer should ensure that all CLI-derived strings (like commit messages, PR titles, etc.) are strictly escaped using a robust JSON serializer before being piped to stdout.
Environment
- Action Version:
anthropics/claude-code-action@v1 - Runner:
ubuntu-latest - Node.js:
v18