Image Processing Failure: API Rejects Unrelated Context Image
Open 💬 20 comments Opened Jul 21, 2025 by JVmano
Bug Description
The context is returning on all type of prompts the error ⎿ API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"Could not process image"}} because has a image in the context, even when the image isn't related to the prompt task, it returns this error in a loop, making the thread stuck.
Environment Info
- Platform: darwin
- Terminal: ghostty
- Version: 1.0.56
- Feedback ID: b67410b3-abad-48bf-9621-6df3c289bca8
Errors
[{"error":"Error: Command failed: security find-generic-password -a $USER -w -s \"Claude Code\"\nsecurity: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.\n\n at genericNodeError (node:internal/errors:983:15)\n at wrappedFn (node:internal/errors:537:14)\n at checkExecSyncError (node:child_process:882:11)\n at execSync (node:child_process:954:15)\n at A7 (file:///Users/sephrot/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:797:5848)\n at file:///Users/sephrot/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:709:48013\n at Q (file:///Users/sephrot/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:609:14408)\n at fY (file:///Users/sephrot/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:709:45724)\n at QK (file:///Users/sephrot/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:709:44590)\n at SB (file:///Users/sephrot/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:709:50639)","timestamp":"2025-07-21T14:19:27.942Z"},{"error":"Error: ENOENT: no such file or directory, open '/proc/version'\n at Module.readFileSync (node:fs:441:20)\n at Object.readFileSync (file:///Users/sephrot/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:615:7077)\n at file:///Users/sephrot/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:615:8638\n at Q (file:///Users/sephrot/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:609:14408)\n at kT4 (file:///Users/sephrot/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:709:62815)\n at process.processTicksAndRejections (node:internal/process/task_queues:105:5)","timestamp":"2025-07-21T14:19:28.459Z"},{"error":"Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"Could not process image\"}}\n at V4.generate (file:///Users/sephrot/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1249:6428)\n at dM.makeStatusError (file:///Users/sephrot/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1266:2101)\n at dM.makeRequest (file:///Users/sephrot/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1266:5315)\n at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n at async w81.showErrors (file:///Users/sephrot/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:2670:14158)\n at async w81 (file:///Users/sephrot/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:2210:1704)\n at async mqB (file:///Users/sephrot/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:2670:14009)\n at async file:///Users/sephrot/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:2670:9066\n at async JKA (file:///Users/sephrot/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:2670:1626)\n at async ra (file:///Users/sephrot/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:2670:9036)","timestamp":"2025-07-21T14:19:33.032Z"},{"error":"Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"Could not process image\"}}\n at V4.generate (file:///Users/sephrot/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1249:6428)\n at dM.makeStatusError (file:///Users/sephrot/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1266:2101)\n at dM.makeRequest (file:///Users/sephrot/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1266:5315)\n at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n at async w81.showErrors (file:///Users/sephrot/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:2670:14158)\n at async w81 (file:///Users/sephrot/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:2210:1704)\n at async mqB (file:///Users/sephrot/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:2670:14009)\n at async file:///Users/sephrot/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:2670:
Note: Error logs were truncated.
20 Comments
same issue here, my specific case #6175 attempted to read a .jpg that actually contained html data causing this exact same loop
I was getting this repeatedly even after restarting Claude Code. Switching projects fixed it.
I just ran into something related to this with a 179KB png that I wanted Claude Code to analyze. I started a new session and it proceeded with analyzing the image.
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
I am still seing this issue
still facing this issue:
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"Could not process image"},"request_id":"req_011CWDq6UFkcTA3XCKdbLND9"}Can confirm, this is very much so still an issue:
API Error: 400{"type":"error","error":{"type":"invalid_request_error","message":"Could not process
image"},"request_id":"req_011CWdKWQhhsrD3Vz9roBzu9"}
Still facing
Same! It's crazy, and I think it might be related to Claude trying to read either
.webpimages or broken imagesstill facing
Is there at least a workaround to this?
@SABRYX you can add a rule to CLAUDE.md that says that before reading an image it should validate it first
I have the same issue. Session becomes fully corrupted with repeated errors [0]. I followed @zernie 's rec to update CLAUDE.md, and the second time around in another session with the exact same prompt, I did not have the issue. Not sure if causal, but that unlocked me, thanks!
[0] Examples:
Same Issue on my end too with Claude Code
Fails whether I paste form clipboard or source a file:
The image I'm pasting is a valid PNG:
Same issue. Just tried to have Claude convert downloaded jpg to webP to add to WordPress pattern and got this multiple times
Tried downloading CC0 image myself and feeding it to Claude Code but that did not work either.
It seems that there is another issue which is concerned with corrupt images that produce the same (or similar) behavior: https://github.com/anthropics/claude-code/issues/24387
I screenshot-ted the image and replaced it, it worked.
Update: The workaround hook now uses a subprocess proxy (v9) — instead of passing converted images to the context (which still accumulates), it spawns a fresh
claude --model haikuto analyze each image and returns text only. Zero image data in context, unlimited reads per session.Features: auto-context from session transcript, PostToolUse cleanup, prompt injection resistant.
Gist: https://gist.github.com/justi/8265b84e70e8204a8e01dc9f99b8f1d0
Stress-tested: 15 images in one session, zero errors.
---
cc @JVmano @AndreySoloviev @Ice-Citron @JayFromEpic @SABRYX @Zikoat @agamm @brandon-thomson @jaredthirsk @jasperf @socketbox @t-e-lawrence @theoBLT @timothywangdev @trinanda @zernie
What recommendation? Is there a way to recover from this or is the session doomed? I keep having this issue...
edit: https://gist.github.com/justi/8265b84e70e8204a8e01dc9f99b8f1d0