claude-code - 💡(How to fix) Fix claude --resume fails with 400 "text content blocks must be non-empty" when transcript contains image-with-empty-caption [2 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#54988Fetched 2026-05-01 05:49:11
View on GitHub
Comments
2
Participants
3
Timeline
6
Reactions
0
Timeline (top)
labeled ×4commented ×2

claude --resume <session-id> becomes permanently unusable when the recorded transcript contains a user message with a pasted image and an empty text block. Every retry returns:

API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages: text content blocks must be non-empty"}}

The session can't be recovered without manually editing the JSONL. In my case I had to discard the session entirely and start a fresh one to continue working — losing the in-context state of the conversation.

Error Message

API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages: text content blocks must be non-empty"}}

Root Cause

claude --resume <session-id> becomes permanently unusable when the recorded transcript contains a user message with a pasted image and an empty text block. Every retry returns:

API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages: text content blocks must be non-empty"}}

The session can't be recovered without manually editing the JSONL. In my case I had to discard the session entirely and start a fresh one to continue working — losing the in-context state of the conversation.

Fix Action

Fix / Workaround

  • Sessions become unresumable with no in-product recovery path.
  • The only way I could continue working was to reset/discard the broken session and start a new one from scratch, losing the conversation state.
  • Affected request id (for one occurrence): `req_011CaZx8oPmVvpVv9449Soqn`.
  • Workaround for users who want to preserve the session requires manually editing the JSONL transcript.

Code Example

API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages: text content blocks must be non-empty"}}

---

$ jq -c 'select(.message.content | type=="array") |
   select(.message.content[]? | (type=="object") and .type=="text"
     and (.text=="" or .text==null))
   | {uuid, type, role: .message.role, content_types: [.message.content[].type]}' \
   <session>.jsonl

{"uuid":"668a...fe3d","type":"user","role":"user","content_types":["image","text"]}

---

{
  "role": "user",
  "content": [
    { "type": "image", "source": {} },
    { "type": "text", "text": "" }
  ]
}
RAW_BUFFERClick to expand / collapse

Summary

claude --resume <session-id> becomes permanently unusable when the recorded transcript contains a user message with a pasted image and an empty text block. Every retry returns:

API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages: text content blocks must be non-empty"}}

The session can't be recovered without manually editing the JSONL. In my case I had to discard the session entirely and start a fresh one to continue working — losing the in-context state of the conversation.

Reproduction

  1. In a Claude Code session, paste an image without typing any accompanying text and submit.
  2. Let the session end (or hit a context limit) and run claude --resume <session-id>.
  3. The first turn after resume fails with the 400 above.

Concrete evidence

In an affected session log:

$ jq -c 'select(.message.content | type=="array") |
   select(.message.content[]? | (type=="object") and .type=="text"
     and (.text=="" or .text==null))
   | {uuid, type, role: .message.role, content_types: [.message.content[].type]}' \
   <session>.jsonl

{"uuid":"668a...fe3d","type":"user","role":"user","content_types":["image","text"]}

The recorded message body contains:

{
  "role": "user",
  "content": [
    { "type": "image", "source": {} },
    { "type": "text", "text": "" }
  ]
}

The Anthropic API now rejects empty text blocks, so any resume attempt that replays this message fails.

Impact

  • Sessions become unresumable with no in-product recovery path.
  • The only way I could continue working was to reset/discard the broken session and start a new one from scratch, losing the conversation state.
  • Affected request id (for one occurrence): `req_011CaZx8oPmVvpVv9449Soqn`.
  • Workaround for users who want to preserve the session requires manually editing the JSONL transcript.

Suggested fix

One or more of:

  1. Don't record empty text blocks — when a user pastes an image with no caption, write only the `image` block.
  2. Sanitize on replay — `claude --resume` should drop or repair empty text blocks before sending.
  3. Add `claude --resume --repair` or a similar maintenance command so users don't have to abandon the session.

Environment

  • Claude Code (current build at time of failure)
  • Linux 6.8.0-106-generic, bash, OS user-level install

extent analysis

TL;DR

The most likely fix is to sanitize the recorded transcript by dropping or repairing empty text blocks before resuming a session.

Guidance

  • Identify and remove empty text blocks from the recorded transcript JSONL file to prevent the API error.
  • Consider implementing a sanitization step in the claude --resume command to automatically drop or repair empty text blocks.
  • Manually editing the JSONL transcript to remove empty text blocks can serve as a temporary workaround.
  • Adding a --repair option to the claude --resume command could provide a convenient way to fix affected sessions without abandoning them.

Example

// Before sanitization
{
  "role": "user",
  "content": [
    { "type": "image", "source": {} },
    { "type": "text", "text": "" }
  ]
}

// After sanitization
{
  "role": "user",
  "content": [
    { "type": "image", "source": {} }
  ]
}

Notes

The provided jq command can be used to identify affected sessions by detecting empty text blocks in the transcript.

Recommendation

Apply workaround: Manually edit the JSONL transcript to remove empty text blocks or implement a sanitization step in the claude --resume command to automatically fix affected sessions. This approach allows users to recover from the issue without losing conversation state.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix claude --resume fails with 400 "text content blocks must be non-empty" when transcript contains image-with-empty-caption [2 comments, 3 participants]