[BUG] Valid text incorrectly parsed as empty, causing unrecoverable 400 error
Resolved 💬 2 comments Opened Feb 4, 2026 by kendal1234 Closed Feb 5, 2026
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?
Bug: Valid text content blocks incorrectly interpreted as empty, causing unrecoverable 400 errors
Description
Claude Code incorrectly interprets valid, non-empty text content blocks as empty/whitespace-only, triggering API 400 errors. Once this occurs, all subsequent API calls fail, including /compact, making it impossible to continue the session without losing all context.
Error Message
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages: text content blocks must contain non-whitespace text"},"request_id":"req_011CXorGXRzZRLY5fcRKndS7"}
Expected Behavior
- Valid text content should be correctly transmitted to the API
- Messages with actual content should never trigger "must contain non-whitespace text" errors
Actual Behavior
- Non-empty text content is being misinterpreted as empty
- The API rejects the request with a 400 error
- No recovery path exists other than
/clear, which destroys all context /compactfails with the same error, offering no escape
Impact
- High friction: Users lose significant context and must rebuild expensive conversation state
- No warning: The error occurs suddenly with no indication of root cause
- No recovery: Even built-in recovery tools (
/compact) fail - Silent corruption: Users have no visibility into what went wrong with their valid input
Environment
- Claude Code Version: [2.1.31]
- OS: [macOS 15.7.3,]
- Shell: [zsh]
- Terminal: [Terminal.app]
- Locale/Encoding: [US.UTF-8]
Additional Context
- The user's input is valid and non-empty
- There is no indication of what content is being misinterpreted
- Long coding sessions accumulate significant context that is expensive to rebuild
- Users have no way to inspect the conversation history to diagnose the issue
What Should Happen?
Error 400, 500, or other similar issues should not require context destruction.
Error Messages/Logs
Steps to Reproduce
- Use Claude Code (CLI) in a session with accumulated context
- At some point (trigger unclear), a valid message is incorrectly parsed/encoded
- Attempt to continue the conversation → 400 error
- Attempt
/compactto recover → Same 400 error - Session is now unrecoverable; context must be rebuilt
Claude Model
Sonnet (default)
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.31
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗