claude-code - 💡(How to fix) Fix [BUG] Submitting a screenshot with no text causes unrecoverable 400 error loop [1 comments, 2 participants]

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…
GitHub stats
anthropics/claude-code#56409Fetched 2026-05-06 06:28:50
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Timeline (top)
labeled ×5commented ×1

Error Message

API Error: 400 {"type":"error","error":{"type":"invalid_request_error", "message":"messages.150.content.1.text: cache_control cannot be set for empty text blocks"},"request_id":"req_011Cajx315Mf8Q3vybduyYCs"}

API Error: 400 {"type":"error","error":{"type":"invalid_request_error", "message":"messages: text content blocks must be non-empty"}, "request_id":"req_011CajxAvy2DYSUKYBEDLbdE"}

Root Cause

API Error: 400 {"type":"error","error":{"type":"invalid_request_error", "message":"messages.150.content.1.text: cache_control cannot be set for empty text blocks"},"request_id":"req_011Cajx315Mf8Q3vybduyYCs"} API Error: 400 {"type":"error","error":{"type":"invalid_request_error", "message":"messages: text content blocks must be non-empty"}, "request_id":"req_011CajxAvy2DYSUKYBEDLbdE"} Root cause (as best I can tell)

Code Example

API Error: 400 {"type":"error","error":{"type":"invalid_request_error",
"message":"messages.150.content.1.text: cache_control cannot be set for
empty text blocks"},"request_id":"req_011Cajx315Mf8Q3vybduyYCs"}

API Error: 400 {"type":"error","error":{"type":"invalid_request_error",
"message":"messages: text content blocks must be non-empty"},
"request_id":"req_011CajxAvy2DYSUKYBEDLbdE"}
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?

Pasting a screenshot into the Claude Code chat and pressing Enter without typing any accompanying text triggers a 400 error loop. Once it starts, every subsequent message fails and the session becomes unusable.

Two errors appear in rotation:

API Error: 400 {"type":"error","error":{"type":"invalid_request_error", "message":"messages.150.content.1.text: cache_control cannot be set for empty text blocks"},"request_id":"req_011Cajx315Mf8Q3vybduyYCs"} API Error: 400 {"type":"error","error":{"type":"invalid_request_error", "message":"messages: text content blocks must be non-empty"}, "request_id":"req_011CajxAvy2DYSUKYBEDLbdE"} Root cause (as best I can tell)

When an image is submitted with no text, Claude Code appears to construct a message with an empty text block alongside the image block — {"type": "text", "text": ""}. The API rejects empty text blocks outright, and also rejects cache_control being set on them. Claude Code then retries rather than recovering, looping indefinitely.

To reproduce

Open any session Paste a screenshot into the chat input Press Enter without typing any text Observe 400 errors begin and repeat indefinitely This reproduced across two separate fresh sessions on the same day.

Expected behavior

Claude Code should either strip empty text blocks before sending, or treat a bare image submission as valid (no text block needed) A client-side 400 (malformed payload) should not trigger retries — it should surface a clear error and stop Environment

Platform: Claude Code web (claude.ai/code) Request IDs: req_011Cajx315Mf8Q3vybduyYCs, req_011CajxAvy2DYSUKYBEDLbdE, req_011CajxCi3hepG2D3xAFkeDU, req_011CajxH8RWa2jZBWRAqhvZk

What Should Happen?

it should look at the screenshot and consider it in the context of surrounding chats

Error Messages/Logs

API Error: 400 {"type":"error","error":{"type":"invalid_request_error",
"message":"messages.150.content.1.text: cache_control cannot be set for
empty text blocks"},"request_id":"req_011Cajx315Mf8Q3vybduyYCs"}

API Error: 400 {"type":"error","error":{"type":"invalid_request_error",
"message":"messages: text content blocks must be non-empty"},
"request_id":"req_011CajxAvy2DYSUKYBEDLbdE"}

Steps to Reproduce

paste an image without any text

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

No response

Claude Code Version

web version, i dont know where to find the version, and it's stuck in 400 errors

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Other

Additional Information

No response

extent analysis

TL;DR

The issue can be fixed by modifying Claude Code to either strip empty text blocks before sending or treat a bare image submission as valid.

Guidance

  • Verify that the issue is caused by the empty text block in the message payload by checking the API request payload.
  • Check the Claude Code codebase for the logic that constructs the message payload and identify where the empty text block is being added.
  • Consider adding a check to remove empty text blocks before sending the payload to the API.
  • If the issue is caused by the retry mechanism, consider modifying the retry logic to handle 400 errors differently.

Example

No code snippet can be provided without knowing the specific codebase, but the fix might involve modifying a function that constructs the message payload, for example:

def construct_message_payload(image):
    # ...
    text_block = {"type": "text", "text": ""}
    if text_block["text"] == "":
        # Remove or modify the text block
        pass
    # ...

Notes

The exact fix will depend on the specific implementation of Claude Code and the Anthropic API. The provided error messages and logs suggest that the issue is caused by the empty text block, but further investigation is needed to determine the root cause.

Recommendation

Apply a workaround to strip empty text blocks or treat bare image submissions as valid, as this is likely to fix the issue and prevent the 400 error loop.

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