anthropics / anthropics/claude-code-action

[Bug] JSON Parse Error (13310) in Claude Code Action when commit messages contain Markdown links

Open
#753 0 comments 1 reaction 0 assignees View on GitHub
bug p1
Dominant language
TypeScript
Stars
8.9k
Forks
2.1k
Avg merge
3d 9h
Merged PRs (30d)
10

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**

```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`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.