claude-code - 💡(How to fix) Fix [Bug] Anthropic API Error: cache_control cannot be set for empty text blocks when pasting images [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#53205Fetched 2026-04-26 05:21:42
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Author
Timeline (top)
labeled ×5commented ×1

Error Message

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

Code Example

[]
RAW_BUFFERClick to expand / collapse

Bug Description リモートコントロール(claude.ai web)から画像を貼り付けると、以下のAPIエラーで送信が失敗します。

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

環境:

  • Claude Code v2.1.119
  • Windows 11
  • リモートコントロール(ブラウザ)から画像貼り付け時に発生

確認済み:

  • v2.1.119 へのアップデート → 効果なし
  • ハード再読込(Ctrl+Shift+R)→ UIが変わらず効果なし
  • 画像貼り付け前にテキストを1文字入力 → 効果なし
  • 1度に貼る画像を1枚に制限 → 効果なし

別プロジェクトでは同じ操作でエラーが出ず、画像添付UIの表示も微妙に異なるため、フロントエンド側のメッセージ構築ロジックの問題と推測しています。

Environment Info

  • Platform: win32
  • Terminal: vscode
  • Version: 2.1.119
  • Feedback ID: 8cf14560-dc0c-4336-98e5-38b63838921d

Errors

[]

extent analysis

TL;DR

The issue can be potentially resolved by modifying the frontend message construction logic to handle empty text blocks when pasting images from a remote control.

Guidance

  • Investigate the message construction logic in the frontend code to identify the cause of the cache_control cannot be set for empty text blocks error.
  • Verify if the error occurs when pasting images from other sources, such as local files, to determine if the issue is specific to the remote control.
  • Check the differences in the UI and message construction logic between the project that works and the one that doesn't to identify potential discrepancies.
  • Consider adding a temporary workaround to handle empty text blocks when pasting images, such as automatically adding a space or a placeholder text.

Notes

The issue seems to be specific to the frontend logic and the remote control, and the provided error message suggests that the problem lies in the way the message is constructed when pasting images.

Recommendation

Apply workaround: Modify the frontend message construction logic to handle empty text blocks when pasting images from a remote control, as this seems to be the most likely cause of the issue.

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] Anthropic API Error: cache_control cannot be set for empty text blocks when pasting images [1 comments, 2 participants]