fix: treat image file extensions as case-insensitive - #5588
Closed
tonycoder-hub wants to merge 1 commit into
Closed
Conversation
is_image_file() compared the filename against the lowercase entries in IMAGE_EXTENSIONS with str.endswith(), so common uppercase names like DSC_0001.JPG or scan.PDF were not recognized as images. Those files were then read as text, which fails with a UnicodeDecodeError and reports "Unable to read", and they also bypassed the model vision/PDF support checks in /add. Co-authored-by: Tony Coder <407243179@qq.com>
Author
|
Closing as stale — opened on or before 2026-08-17 and still unmerged. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
is_image_file()compared filenames against the lowercaseIMAGE_EXTENSIONSset withstr.endswith(), soDSC_0001.JPGandscan.PDFwere treated as text.InputOutput.read_text()then opened the binary as text (UnicodeDecodeError/ "Unable to read"),/addskipped the vision guard, andget_image_message()never sent the image.The filename is now lowercased before the comparison. Distinct from #5587 (OpenRouter variant lookup).
Test plan
python -m pytest tests/basic/test_utils.py -v→ 3 passed