claude --resume fails with 400 "text content blocks must be non-empty" when transcript contains image-with-empty-caption

Resolved 💬 3 comments Opened Apr 30, 2026 by Ibrahim-Aldhaheri Closed May 31, 2026

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

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗