anthropics / anthropics/claude-code-action
[Bug] JSON Parse Error (13310) in Claude Code Action when commit messages contain Markdown links
- 主要言語
- TypeScript
- スター
- 8.9k
- フォーク
- 2.1k
- 平均マージ
- 3日 9時間
- マージ済み PR(30日)
- 10
説明
## **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**
```text
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)**
1. **Scenario A (Success):** PR with a simple commit message (e.g., "fix: update logic"). ✅ **Works**
2. **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)](https://www.google.com/search?q=url)"). ❌ **Fails with Error 13310**
3. **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`
コントリビューションガイド
評価
この issue はまだ評価されていません。