Return BadImage for a truncated image - #3502
Merged
Merged
Conversation
``Image.verify`` raises ``OSError`` as well as ``SyntaxError`` -- for example on a PNG whose ``IDAT`` data is present but whose ``IEND`` chunk is missing. ``Image.open`` succeeds for such a file, so ``validate_image_is_image`` does not reject it first and the bare ``OSError`` escaped the request. Real Vuforia answers ``422 BadImage`` for these images, verified against a live account, so the mock now does too. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01H7tNiBpHomY5ShxZjQyWsf
adamtheturtle
had a problem deploying
to
vuforia
August 27, 2026 06:48 — with
GitHub Actions
Failure
adamtheturtle
had a problem deploying
to
vuforia
August 27, 2026 06:48 — with
GitHub Actions
Failure
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.
Fixes #3498.
Image.verifyraisesOSErroras well asSyntaxError— for example on aPNG whose
IDATdata is present but whoseIENDchunk is missing.Image.opensucceeds for such a file, sovalidate_image_is_imagedoes notreject it first, and the bare
OSErrorescaped the request: the mock failedto respond at all.
validate_image_integritynow catches both.open_imageruns outside thetry, so anything which cannot be opened at all is still rejected byvalidate_image_is_image.Verification
make_truncated_png_filebuilds the file from the reproduction in the issue.New
TestImage::test_truncatedtests foradd_targetandupdate_targetfail with
OSError: truncated PNG filewithout the fix and pass with it, onthe in-memory mock, the in-memory Docker application and real Vuforia — real
Vuforia answers
422 BadImage, so the mock now matches.The Query API needs no change: it never calls
verify, and real Vuforiaaccepts the same truncated PNG there, returning an empty match list. Checked
against a live account.
The new
update_targettest needed aci_patternentry; theadd_targetone is already covered by the
TestImagepattern.🤖 Generated with Claude Code
https://claude.ai/code/session_01H7tNiBpHomY5ShxZjQyWsf