[BUG] asking claude to read an invalid PDF file corrupts the session

Resolved 💬 2 comments Opened Jan 22, 2026 by abayley Closed Jan 22, 2026

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?

I asked Claude to read an invalid PDF file (it turned out to be a small text file with a .pdf suffix). I get an API error 400 "The PDF specified was not valid" (expected) but then I am unable to instruct claude to do anything else. It appears to attempt to re-read the file on each new turn.

What Should Happen?

Claude should ignore the invalid file.

Error Messages/Logs

∴ Thinking…                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                         
  Let me read a couple of these PDF files to see if they're valid.                                                                                                                                                                                       
                                                                                                                                                                                                                                                         
⏺ Read(/Users/alistairbayley/git/nzlaw/acts/pdf/A/A.E.-Thorpe-Limited-Act-1990.pdf)                                                                                                                                                                      
  ⎿  PreToolUse:Read hook succeeded                                                                                                                                                                                                                      
  ⎿  Read PDF (131 bytes)                                                                                                                                                                                                                                
  ⎿  PostToolUse:Read hook succeeded                                                                                                                                                                                                                     
  ⎿  API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.34.content.0.pdf.source.base64.data: The PDF specified was not valid."},"request_id":"req_011CXPEjg2tYFuHcwo9idED8"}                                     
                                                                                                                                                                                                                                                         
❯ a bunch of the PDF files just contain plain text, and the first line is `version https://git-lfs.github.com/spec/v1`. please identify all of these PDF files and delete them (maybe with a shell script?)                                              
  ⎿  ⧉ Selected 3 lines from acts/pdf/B/Bail-Act-2000.pdf in Visual Studio Code                                                                                                                                                                          
  ⎿  API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.34.content.0.pdf.source.base64.data: The PDF specified was not valid."},"request_id":"req_011CXPFFNcyPWnrFf8LT7tZi"}                                     
                                                                                                                                                                                                                                                         
❯ are you OK?                                                                                                                                                                                                                                            
  ⎿  API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.34.content.0.pdf.source.base64.data: The PDF specified was not valid."},"request_id":"req_011CXPFGTzTZKSSQVcKp7cE2"}                                     
                                                                                                                                                                                                                                                         
❯ /diary                                                                                                                                                                                                                                                 
  ⎿  API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.34.content.0.pdf.source.base64.data: The PDF specified was not valid."},"request_id":"req_011CXPFHDMAkuefZkrWQorpH"}

Steps to Reproduce

echo "hello" > test.pdf
claude "read test.pdf"

You should get API Error 400. After this you cannot converse with claude, until you type /clear.

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.17 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

VS Code integrated terminal

Additional Information

_No response_

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗