API Error 400: text content blocks must contain non-whitespace text
Resolved 💬 4 comments Opened Feb 5, 2026 by JobersIA Closed Mar 6, 2026
Bug Report
Error
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages: text content blocks must contain non-whitespace text"},"request_id":"req_011CXqXVfVqMJd8rzkVKPZDM"}
Description
Claude Code throws a 400 error from the Anthropic API indicating that a text content block with empty or whitespace-only content was sent in a message.
Error Details
- HTTP Status: 400
- Error Type:
invalid_request_error - Message:
messages: text content blocks must contain non-whitespace text - Request ID:
req_011CXqXVfVqMJd8rzkVKPZDM
Expected Behavior
Claude Code should validate that all text content blocks contain non-whitespace text before sending requests to the API. Empty or whitespace-only blocks should be filtered out or replaced with meaningful content.
Possible Causes
- A tool returning an empty result that gets included as an empty text block
- Context compaction leaving an empty text block
- A hook returning a blank response
Environment
- Platform: Windows
- Date: 2025-02-05
- Model: claude-opus-4-6
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗