claude-code - 💡(How to fix) Fix [BUG] Cloud session permanently stuck on "API Error 400: text content blocks must be non-empty" — no in-app recovery path

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…

Error Message

API Error: 400 messages: text content blocks must be non-empty

Code Example

API Error: 400 messages: text content blocks must be non-empty
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

A long-running cloud Claude Code session became permanently unusable: every new message I send returns

API Error: 400 messages: text content blocks must be non-empty

Closing and reopening the desktop app does not help (the failing state is server-side, baked into the session's message history). There is no visible way in the desktop UI to:

  • edit or delete the offending turn
  • retry a sanitized version of the last message
  • fork the session from an earlier known-good turn
  • export the transcript as JSON for recovery

The session is still readable — the transcript displays fine — but completely unusable for further work. The accumulated context (multi-phase release planning, code paths, decisions, file references built up over hours) is trapped: I can see it but not act on it.

For heavy multi-hour tasks this is a high-impact failure mode. The session represents real work that cannot be recovered or continued.

Session affected: https://claude.ai/code/session_012ZMz5D3WV8UG4gyutJxc9s

What Should Happen?

The client should not let an invalid payload reach the API in the first place. Specifically:

  1. Strip or coalesce empty text content blocks before sending. The Anthropic Messages API has documented this constraint forever; the client knows the shape of its own payload.

  2. If a 400 with this exact error code does come back, the UI should surface a one-click recovery: "Edit last message", "Resend without empty block", or "Fork from previous turn".

  3. Provide an "Export conversation" affordance (JSON or markdown) on every session, so a stuck session never costs the user the work it contains.

  4. Optionally: detect that a session is in a permanently-failing state (same 400 on three consecutive sends) and prompt the user to fork into a fresh session, carrying forward as much context as possible.

Error Messages/Logs

API Error: 400 messages: text content blocks must be non-empty

Steps to Reproduce

I cannot reproduce this on demand — the bad turn entered the history at some point during normal usage. Likely triggers (based on the API error meaning "a content block in messages had an empty text field"):

  1. Open a cloud Claude Code session (claude.ai/code/<session-id>) in the desktop app.
  2. During a long session, send a message that contains an image, file, or paste with no accompanying text caption. (This is the most common path to an empty text block in the request.)
    • Alternatively: a tool result with empty stdout being wrapped as an empty text block.
  3. From that point onward, every subsequent send returns the 400.
  4. Restarting the desktop app, closing and reopening the session, or signing out and back in does not clear the state.

If reproducing in a debug build, instrument the client's payload serializer to log the messages array before send — the offending message will have a content array containing { "type": "text", "text": "" } (or "text": "\n" or similar whitespace).

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

v2.1.143

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Other

Additional Information

  • Session ID: session_012ZMz5D3WV8UG4gyutJxc9s
  • Desktop app local data dir on my machine: ~/Library/Application Support/Claude
  • I attempted: close & reopen the app (no change), open the session URL in a browser (same 400 on send, reads work)
  • The desktop UI offers no per-message edit/delete/retry buttons that I could find
  • Approximate session length when it broke: multi-day, ~hundreds of turns covering a phased release plan for a Cloudflare-deployed React app. The accumulated context is what made this loss painful.

Suggested priority: medium-high for sessions used in production engineering work; the failure mode silently wipes out hours of context with no warning and no recovery.

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 [BUG] Cloud session permanently stuck on "API Error 400: text content blocks must be non-empty" — no in-app recovery path