Preflight Checklist
What's Wrong?
When sending an image with mismatched extension and content (e.g., a JPEG file saved with .png extension), Claude Code determines
the MIME type from the file extension and sends it to the Anthropic API as image/png. The API detects the mismatch and returns a
400 error, which crashes the entire session.
This commonly occurs with screenshot tools like "Nano Banana Pro" that save JPEG content with .png extension.
What Should Happen?
Claude Code should detect the actual image format using magic bytes (file signature) instead of relying on the file extension. This
would allow correct MIME type detection regardless of the file extension.
For example:
- PNG magic bytes:
89 50 4E 47 0D 0A 1A 0A
- JPEG magic bytes:
FF D8 FF
- WebP magic bytes:
52 49 46 46 ... 57 45 42 50
Error Messages/Logs
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.1.content.24.image.source.base64.data:
Image does not match the provided media type image/png"},"request_id":"req_011CVuYmAGosipwSBTKU9Xv7"}
Steps to Reproduce
- Create a fake PNG file (JPEG content with .png extension):
# Take a JPEG screenshot and save as .png, or:
cp some_image.jpg fake_image.png
- Start a Claude Code session
- Paste or reference the fake PNG image in the conversation
- Session crashes with "Image does not match the provided media type" error
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
No response
Claude Code Version
2.0.61
Platform
Other
Operating System
Windows
Terminal/Shell
WSL (Windows Subsystem for Linux)
Additional Information
Suggested fix:
Read the first 12 bytes of the image file and detect MIME type from magic bytes before sending to the API.
Workaround:
Rename the file to match its actual content type before sending:
file image.png # Check actual type
mv image.png image.jpg # Rename if needed
Preflight Checklist
What's Wrong?
When sending an image with mismatched extension and content (e.g., a JPEG file saved with
.pngextension), Claude Code determinesthe MIME type from the file extension and sends it to the Anthropic API as
image/png. The API detects the mismatch and returns a400 error, which crashes the entire session.
This commonly occurs with screenshot tools like "Nano Banana Pro" that save JPEG content with
.pngextension.What Should Happen?
Claude Code should detect the actual image format using magic bytes (file signature) instead of relying on the file extension. This
would allow correct MIME type detection regardless of the file extension.
For example:
89 50 4E 47 0D 0A 1A 0AFF D8 FF52 49 46 46 ... 57 45 42 50Error Messages/Logs
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.1.content.24.image.source.base64.data: Image does not match the provided media type image/png"},"request_id":"req_011CVuYmAGosipwSBTKU9Xv7"}Steps to Reproduce
# Take a JPEG screenshot and save as .png, or: cp some_image.jpg fake_image.pngClaude Model
Opus
Is this a regression?
I don't know
Last Working Version
No response
Claude Code Version
2.0.61
Platform
Other
Operating System
Windows
Terminal/Shell
WSL (Windows Subsystem for Linux)
Additional Information
Suggested fix:
Read the first 12 bytes of the image file and detect MIME type from magic bytes before sending to the API.
Workaround:
Rename the file to match its actual content type before sending: