Image Upload Exceeds Size Limit Causing Persistent API Request Failure
Open 💬 39 comments Opened Jul 3, 2025 by alessandrobologna
Bug Description
after submitting an image too large, the context is polluted and any other request returns the error API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.17.content.1.image.source.base64.data: At least one of the image dimensions exceed max allowed size for many-image requests: 2000 pixels"}}
Environment Info
- Platform: darwin
- Terminal: cursor
- Version: 1.0.41
- Feedback ID: 635919c9-d04d-4562-9842-2a0a15d8e011
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 JI (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:702:3921)\n at file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:623:9038\n at Q (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:526:13327)\n at _X (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:623:8184)\n at w_ (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:623:7265)\n at U9 (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:623:11432)","timestamp":"2025-07-03T16:45:23.855Z"},{"error":"Error: Tool mcp__puppeteer__puppeteer_click not found\n at dT2 (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:1958:5596)\n at ZU (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:65:19802)\n at UP (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:42556)\n at wP (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:38105)\n at o$ (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:38033)\n at MU (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:37887)\n at EJ (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:34977)\n at f5 (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:65:4822)\n at DB (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:32233)\n at A.Q.updateContainer (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:71:1835)","timestamp":"2025-07-03T16:45:27.222Z"},{"error":"Error: Tool mcp__puppeteer__puppeteer_click not found\n at dT2 (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:1958:5596)\n at ZU (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:65:19802)\n at UP (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:42556)\n at wP (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:38105)\n at o$ (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:38033)\n at MU (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:37887)\n at EJ (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:34977)\n at f5 (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:65:4822)\n at DB (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:32233)\n at A.Q.updateContainer (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:71:1835)","timestamp":"2025-07-03T16:45:27.236Z"},{"error":"Error: Tool mcp__puppeteer__puppeteer_screenshot not found\n at dT2 (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:1958:5596)\n at ZU (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:65:19802)\n at UP (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:42556)\n at wP (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:38105)\n at o$ (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:38033)\n at MU (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:37887)\n at EJ (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:34977)\n at f5 (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:65:4822)\n at DB (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:32233)\n at A.Q.updateContainer (file:///Users
Note: Error logs were truncated.
39 Comments
I didn’t upload any images and still encountered this issue—I only asked CC to modify the copy on the webpage and didn’t upload any images to him. After this error appeared, even the /compact command started returning the same error.
Found my session afflicted with this same thing soon (within a day) after I started working with the chrome-devtools MCP server. That was going great until the session was entirely incapacitated by this error. And yep,
/compactis failing too in this session — presumably because it's trying to read that same poisoned item in the context. I'll hazard a guess that a screenshot of the remote-controlled Chrome window (or of a canvas that I have in there in a scrollable container) landed in the context despite violating some size-limit invariant, and then there's no coming back from that.Error: Error during compaction: Error: API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.380.content.0.image.source.base64.data: At least one of
the image dimensions exceed max allowed size: 8000 pixels"},"request_id":"req_011CU35RmzHC6WGfCL6kKbKB"}
Same here! Would be nice to have a command to remove the bad message from the context to compact or instruct otherwise.
My Experience: 12+ Hours of Work Lost
I encountered this exact issue and lost over 12 hours of productive working history with Claude Code. The session became completely unrecoverable after an image >8000 pixels was added to the context.
Impact:
Critical Need: This needs a recovery mechanism urgently. Suggestions:
/remove-message <index>)/compactresilient to skip/remove invalid messages instead of failing/recovercommand to sanitize corrupted contextsThis is a severe UX issue that makes the tool feel fragile when working with visual content, especially when using MCP servers that generate screenshots automatically.
---
_Meta note: This comment was drafted by Claude Code itself—the very tool that caused the problem. Even the offender agrees this needs fixing! 😅_
/rewind worked for me as a recovery mechanism. I went back in the context stack however-many prompts to before the bad image from Chrome was added.
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.8.content.5.image.source.base64.data: At least one of the image dimensions exceed max allowed size: 8000 pixels"},"request_id":"req_011CVFsFR3Yo8qKa9SEVzj8F"}Has any of the dev team looked at this?
Same issue to be
``
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.7.content.5.image.source.base64.data: At least one of the``image dimensions exceed max allowed size: 8000 pixels"},"request_id":"req_011CVFv8L4ojR1WvfaonMrw1"}
Well thanks for stating the obvious fella, my query was more in relation to has anyone looked at this from a dev POV with the view to fixing the ability to recover cleanly
This is a vexing problem and I have been burned by it many times. Yesterday I decided to take a new approach. I use Claude Code on a MacBook Pro with Sequoia. I asked it to write a Bash script to check the pixel and byte sizes to ensure they are within the limits for any image view. If it is too large, it should use ImageMagick to resize or make a copy with the appropriate specs.
I further instructed it to add it to CLAUDE.md as a priority rule to use the script every time an image might be read into the session.
I decided to add some other instructions such as a mandate of using shellcheck on Bash scripts and lint for PHP and Python before they try to run them. I was also tired of nonsensical time references to I required the session to check the current date-time before making a statement.
I can provide the code for image screening (
check_image_previe.sh). It is 154 lines with comments.In the CLAUDE.md below I have added backslashes before the triple-backticks for the formatting in github. But they may cause a problem if left in for use. With the right prompt, this would be generated by Claude Code. But it shows the intent.
Having worked with Claude Code since May 2025, this is hopefully going to rein in some of the most frequent issues I have with it. Something akin to this should be part of the core system. Creating a fatal error loop that can't be resolved without starting a new session is a serious blocker for professional use of an otherwise good system.
James D. Keeline
Hey everyone,
ran into the same problem that an oversized image corrupted my conversation with Claude Code. Since it had been running for 1 hour before - without any additional message from me - I was not able to simply rewind. Thus, I looked into the directory, which stores the conversation files (simple .jsonl files) and then basically asked Claude to fix itself. Here is its solution, which worked like a charm. Hope this helps some people until a proper fix is out:
Fixing Claude Code Conversation Stuck on Oversized Image
The Problem
When Claude Code tries to read an image larger than 5MB, the API rejects it with an error like:
The base64 image data is already saved in the conversation history (
.jsonlfile), so every subsequent message keeps sending the same oversized image, causing a loop of API errors. Even new messages won't work.The Solution
1. Find the conversation file
Conversation files are stored in
~/.claude/projects/<project-path>/with UUID-style names:2. Identify the problematic lines
Find which lines are huge (contain base64 image data):
Lines with millions of bytes are the culprits (normal lines are a few KB at most).
3. Create a backup
4. Fix with this Python script
5. Restart Claude Code
The conversation should now load without errors.
Key Points
toolUseResultkey entirely (not just modify it) - otherwise Claude Code crashes trying to render it withCannot destructure property 'numLines' from nulltool_use_idto maintain conversation continuityPrevention
Before reading large images, resize them first:
Ah, that's a great idea, I already have directives to manage the same repetitive calls that just pipe to <grep|jq|awk,whatever> and to stuff/redirect calls into a file and use the output file instead.
Never occurred to me to check image ... derp 🙂
Since I already have ffmpeg, I figured let it do the dirty work, no special scripts.
I like the shellcheck and lint suggestions, that should prevent some wasted confirmations.
As I sat on this draft for a day, another submitter had a similar but cleaner directives: see jhilgert's solution using convert and ImageMagick
________________________________
From: Keeline @.*>
Sent: Sunday, November 23, 2025 7:26 PM
To: anthropics/claude-code @.*>
Cc: Jim Sander @.>; Comment @.>
Subject: Re: [anthropics/claude-code] Image Upload Exceeds Size Limit Causing Persistent API Request Failure (Issue #2939)
CAUTION: This is an external email originated outside of Uniphore. Do not click links or open attachments unless you recognize the sender and know the content is safe.
[https://avatars.githubusercontent.com/u/11981137?s=20&v=4]Keeline left a comment (anthropics/claude-code#2939)<https://github.com/anthropics/claude-code/issues/2939#issuecomment-3568641667>
This is a vexing problem and I have been burned by it many times. Yesterday I decided to take a new approach. I use Claude Code on a MacBook Pro with Sequoia. I asked it to write a Bash script to check the pixel and byte sizes to ensure they are within the limits for any image view. If it is too large, it should use ImageMagick to resize or make a copy with the appropriate specs.
I further instructed it to add it to CLAUDE.md as a priority rule to use the script every time an image might be read into the session.
I decided to add some other instructions such as a mandate of using shellcheck on Bash scripts and lint for PHP and Python before they try to run them. I was also tired of nonsensical time references to I required the session to check the current date-time before making a statement.
I can provide the code for image screening (check_image_previe.sh). It is 154 lines with comments.
In the CLAUDE.md below I have added backslashes before the triple-backticks for the formatting in github. But they may cause a problem if left in for use. With the right prompt, this would be generated by Claude Code. But it shows the intent.
Having worked with Claude Code since May 2025, this is hopefully going to rein in some of the most frequent issues I have with it. Something akin to this should be part of the core system. Creating a fatal error loop that can't be resolved without starting a new session is a serious blocker for professional use of an otherwise good system.
James D. Keeline
Claude Code Instructions
Image Preview Safety
CRITICAL: Always use
./check_image_preview.sh <image_file>before reading any image with the Read tool. This prevents Claude Code from attempting to load oversized images that cause infinite error loops and context loss.Image Constraints
--fixflag to auto-create compliant versionsExample Usage
\```bash
Check image before viewing
./check_image_preview.sh "/path/to/image.jpg"
Auto-fix oversized images
./check_image_preview.sh --fix "/path/to/image.png"
If it passes, then safe to use:
Read "/path/to/image.jpg"
\```
This workflow prevents system crashes and preserves work context.
Script Development Standards
Bash Scripts
Always run shellcheck before finalizing any bash script:
\``
bash``/opt/homebrew/bin/shellcheck script_name.sh
\
Fix all warnings and errors. Common issues:
"$var"local var; var=$(command)PHP Scripts
Check syntax before execution:
\``
bash``php -l script_name.php
\
Python Scripts
Use appropriate syntax checkers:
python -m py_compile script.py(built-in)flake8 script.py(if installed)pylint script.py(if installed)Always lint scripts during development to catch errors early.
Temporal References
CRITICAL: Always run
datecommand before making any date/time-based statements or assumptions in conversations.\``
bash``date
\
Current session time reference: Sat Nov 22 22:13:24 PST 2025
This ensures accuracy when discussing:
—
Reply to this email directly, view it on GitHub<https://github.com/anthropics/claude-code/issues/2939#issuecomment-3568641667>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/A6RZPPBXX4HLDAL2IRQU3M336JNEJAVCNFSM6AAAAACAXKPDIOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTKNRYGY2DCNRWG4>.
You are receiving this because you commented.Message ID: @.***>
This transmission may contain privileged and confidential information. It is intended only for the use of the person(s) named above. If you are not the intended recipient, you are hereby notified that any review, dissemination, distribution, or duplication of this communication is strictly prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
PUBLIC
This transmission may contain privileged and confidential information. It is intended only for the use of the person(s) named above. If you are not the intended recipient, you are hereby notified that any review, dissemination, distribution, or duplication of this communication is strictly prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
Hey everyone 👋
After repeatedly facing this issue, I decided to build
claude-code-image-sanitizer
using some of the feedback and insights shared across related issues.
What it does:
Would love any feedback/contributions!
In our case it seems that a fairly large filename is causing this issue. When a screenshot is taken with a Mac it'll be called "Schermafbeelding 2025-12-30 om 10.25.40.png" (Dutch). When we drag&drop to Claude CLI it throws the "image upload exceeds" error, even when it's only 1mb. However when we rename it to "Bug.png" it does process the image correctly.
+1
You have not shared the size in bytes and pixel dimensions for your image. It is very easy to exceed the 2000 pixels in either dimension or the 2 MB byte limit. A Mac screenshot is double resolution (144 dpi vs 72 dpi). Even partial screen caps can do it.
It is probably not related to the length of the file name (as shown) or even the spaces.
The error message from Claude will usually state what is violated (bytes or pixels).
Fwiw, if you don't want to muck around in
.claude... the/clearcommand fixed the issue for meSolution: Claude Code Toolkit
I created a tool to fix this issue:
Optional: Install as MCP Server
For ongoing maintenance, you can add it as an MCP server and ask Claude to check its own health:
Then just ask Claude: "Check my Claude Code health" or "Fix any issues"
Then restart Claude Code.
What it does:
GitHub: https://github.com/AsifKibria/claude-code-toolkit
npm: https://www.npmjs.com/package/@asifkibria/claude-code-toolkit
@AsifKibria
Thanks for tool, but how its help with blocked conversation ? I need quit claude-code, fix with your tool and then resume?
The toolkit does not help the claude chrome extension either so a better way is needed within Claude product suite itself. A way to clear only a previous message is likely what's required. Even just deleting the image with a placeholder like the toolkit is doing.
@DavideDaniel 100% the last request didn’t even really succeed so why bother recovering, I’d be happy to resubmit or adjust and resubmit. Seems like a no brainer fix if they aren’t going to resize it to a size that works.
In my case, I copy/paste data from Excel columns, expecting it to be inserted in Claude as text, but it generated a huge image that broke conversation with
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.6.content.3.image.source.base64.data: At least one of the image dimensions exceed max allowed size: 8000 pixels"},"request_id":"req_011CXRuS9pn1Bzn64KoKZExz"}Context was very important so I did not want to clear it.
The tool from @AsifKibria fixed the issue in seconds. Thank you!!
Yes.
Just run (if you don't want it to be installed globally or as MCP),
npx @asifkibria/claude-code-toolkit healthAnd
npx @asifkibria/claude-code-toolkit fixThen you can continue your chat, without iuuses.
I encountered this problem in claude extension for google chrome :(
Same here. I've been getting this error message for the past couple of days and couldn't find a solution. Any updates?
This is happening for me as well. Using the Claudian plugin with Obsidian. The entire conversation is now blocked after this image size issue.
Cross-posting from ChromeDevTools/chrome-devtools-mcp#879 where this issue is being discussed from the MCP server side.
The problem: MCP servers like
chrome-devtools-mcpreturn screenshots as base64 images that can easily exceed Claude API's dimension limits (8000px for single images, 2000px when 20+ images are in context). When this happens, the Claude Code session becomes permanently corrupted — every subsequent message (including/compact) fails with the same API 400 error, making the entire session unrecoverable without manual intervention.Why this is a Claude Code issue (not just MCP): While MCP servers could add resizing as a workaround, Claude Code should handle this gracefully regardless of the image source. Specifically:
/compactresilient — skip or remove invalid messages instead of crashing on them/remove-messageor/recover) to sanitize corrupted contextsMultiple users are impacted across different MCP servers (chrome-devtools, mobile-mcp, Marionette for Flutter) and even direct image paste. The workarounds people have built (CLAUDE.md rules, external sanitizer scripts, manual .jsonl surgery) show this is a real and recurring pain point.
Ref: ChromeDevTools/chrome-devtools-mcp#879
I have the same issur for Claude Browser extension:
messages.5.content.14.image.source.base64.data: At least one of the image dimensions exceed max allowed size for many-image requests: 2000 pixels
Wow, this issue still hasn't been fixed!
I encountered this issue in version 2.1.78 of VS Code.
<img width="982" height="442" alt="Image" src="https://github.com/user-attachments/assets/f480ef23-d544-4998-8c26-ba651b10325d" />
Nuts eh… it knows it’ll be an issue, so instead of just resizing it and continuing on, just stops and breaks, and that’s I guess just fine?
Workaround: We ran into this too. Images > 2000px break the session.
We added this to our
CLAUDE.mdto force resize after every screenshot capture:sips -Z 1600resizes the image to fit within 1600px (longest side) while keeping aspect ratio. We chain it after everyadb pullorxcrun simctl iocall. Not a fix, but it prevents the crash reliably./tmp/gh-comment-2939.md
<img width="383" height="313" alt="Image" src="https://github.com/user-attachments/assets/9b746d06-6093-4e4c-ae4f-4f6f36c4fc61" />
Same issue in the Claude Browser connector
Got this today, no idea what to do. Can't get past it.
This is in Claude in Chrome.
<img width="369" height="311" alt="Image" src="https://github.com/user-attachments/assets/c11ff447-fdc3-4114-8171-82413e50c3af" />
Same issue in Claude in Chrome.
I guess the issue getting worse.
Host: MacOS
Browser: Chrome Version 146.0.7680.178 (Official Build) (arm64)
Extension: Claude 1.0.66 - Claude in Chrome (Beta)
<img width="345" height="239" alt="Image" src="https://github.com/user-attachments/assets/25da92fa-7ab0-4cd0-94ec-20d84d90452d" />
For folks hitting this specifically when using the chrome-devtools-mcp server: I've opened a PR upstream that adds opt-in CLI flags to cap screenshot size before it's embedded in the MCP response.
PR: https://github.com/ChromeDevTools/chrome-devtools-mcp/pull/1823 (tracked at ChromeDevTools/chrome-devtools-mcp#879)
The flags let operators cap dimensions and switch to JPEG so a single screenshot can't blow past the per-image dimension limits enforced by hosted LLM APIs (typically in the 2000-8000 px range, sometimes lower when many images are in the same request):
(See the PR for instructions on running the branch locally before it's merged.)
Important caveats:
Posting this here because @OrKoN from the chrome-devtools-mcp team explicitly invited a cross-post in ChromeDevTools/chrome-devtools-mcp#879. Hope it helps anyone blocked in the meantime.
💡 Session Recovery Workaround (No ffmpeg needed)
If your session is bricked by an oversized image, here's a clean recovery method that preserves your full context:
~/.claude/projects/(orC:\Users\<You>\.claude\projects\on Windows).jsonlfile (by modified date)/initto re-initialize project context.jsonlfile into the chat and tell Claude: "Analyze this session log and get fully caught up on where we left off."This works because the
.jsonlfiles contain the complete conversation history. Feeding it into a fresh session gives you all the context without the corrupted state (the stuck oversized image causing the 400 error loop).