[BUG] Cloud session permanently stuck on "API Error 400: text content blocks must be non-empty" — no in-app recovery path
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] 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:
- 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.
- 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".
- Provide an "Export conversation" affordance (JSON or markdown) on every session, so a stuck session never costs the user the work it contains.
- 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"):
- Open a cloud Claude Code session (claude.ai/code/<session-id>) in the desktop app.
- 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.
- From that point onward, every subsequent send returns the 400.
- 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.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗