[BUG]
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
When a bash command outputs a data:image/svg+xml;base64,... string to stdout, Claude Code detects it as image data and attempts to send it to the Claude API as a vision/image content block. The Claude API
rejects SVG format (only PNG, JPEG, GIF, WebP are supported), returning:
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"Could not process image"},"request_id":"req_011CZMWyw4DGdP72BBp5VRYm"}
What Should Happen?
Either:
- SVG data URLs should not be intercepted as image data (since the API doesn't support SVG), or
- Claude Code should check the MIME type before sending and only intercept supported formats (PNG, JPEG, GIF, WebP), or
- If the API rejects the image, Claude Code should gracefully fall back to treating the output as plain text rather than crashing
Error Messages/Logs
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"Could not process image"},"request_id":"req_011CZMWyw4DGdP72BBp5VRYm"}
Steps to Reproduce
- Open Claude Code in any project containing an SVG file
- Ask Claude to convert the SVG to a base64 data URL
- Claude runs a bash command like:
python3 -c "
import base64
with open('path/to/image.svg', 'rb') as f:
b64 = base64.b64encode(f.read()).decode()
print(f'data:image/svg+xml;base64,{b64}')
"
- The output is detected as image data: [Image data detected and sent to Claude]
- API returns 400: "Could not process image"
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.81 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗