Bug Description
When Claude Code reads a corrupted/invalid image file (e.g., a .jpg file that actually contains HTML text), the invalid image data remains in the conversation context and causes persistent API 400 errors ("Could not process image") for all subsequent messages, making the entire chat session unusable.
Steps to Reproduce
- Have a file with
.jpg extension that contains invalid data (e.g., <html><body>404</body></html> - a 404 error page saved as .jpg)
- Ask Claude Code to read/analyze this image file
- Claude attempts to read it, receives API error 400
- Every subsequent message in that chat session fails with the same error, even unrelated messages
Example
⏺ Read(path/to/corrupted.jpg)
⎿ Read image (29 bytes)
⎿ API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"Could not process image"}}
❯ hello (completely unrelated message)
⎿ API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"Could not process image"}}
Expected Behavior
- The error should be handled gracefully without corrupting the conversation context
- Invalid image data should be validated/sanitized before being added to the context
- Or at minimum, the user should be able to continue the conversation after an image processing error
Actual Behavior
The chat session becomes completely unusable. The only workaround is to start a new session, losing all conversation history.
Environment
- Claude Code CLI
- macOS (Darwin 24.6.0)
Additional Context
The corrupted file in this case was 29 bytes containing <html><body>404</body></html> - likely a failed download that saved the error page instead of the actual image. This is a common scenario when downloading images from URLs that no longer exist.
Bug Description
When Claude Code reads a corrupted/invalid image file (e.g., a
.jpgfile that actually contains HTML text), the invalid image data remains in the conversation context and causes persistent API 400 errors ("Could not process image") for all subsequent messages, making the entire chat session unusable.Steps to Reproduce
.jpgextension that contains invalid data (e.g.,<html><body>404</body></html>- a 404 error page saved as .jpg)Example
Expected Behavior
Actual Behavior
The chat session becomes completely unusable. The only workaround is to start a new session, losing all conversation history.
Environment
Additional Context
The corrupted file in this case was 29 bytes containing
<html><body>404</body></html>- likely a failed download that saved the error page instead of the actual image. This is a common scenario when downloading images from URLs that no longer exist.