Respond to images with a huge number of pixels - #3410
Merged
Conversation
An image with a small file size can decode to a huge number of pixels. Pillow refuses to open such an image, so the mock raised an uncaught ``DecompressionBombError`` instead of returning a response. Against a real database: * ``POST /targets`` returns ``ImageTooLarge`` above 37748736 pixels, whatever the image's file size, aspect ratio or color space. * The Query API applies no pixel count limit, only its existing maximum width and height of 30000. The mock now opens images with Pillow's decompression bomb protection disabled, and applies the ``POST /targets`` limit. This also fixes an unrelated ``ZeroDivisionError`` raised when rating an image of a single color, which the new tests need in order to make a small file with many pixels. Fixes #3378 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
adamtheturtle
force-pushed
the
adamtheturtle/vws-python-mock-issue-3378
branch
from
August 10, 2026 16:28
4a80c50 to
29a5f4b
Compare
…hon-mock-issue-3378 # Conflicts: # tests/mock_vws/test_query.py
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 #3378. An image with a small file size can decode to a huge number of pixels, which Pillow refuses to open, so both APIs raised an uncaught
DecompressionBombErrorrather than returning a response.Verified against a real database:
POST /targetsreturnsImageTooLargeabove 37748736 pixels whatever the image's file size, aspect ratio or color space (6144x6144 is accepted, 6145x6144 is not), while the Query API applies no pixel count limit at all, only its existing maximum width and height of 30000. The mock now opens images with Pillow's decompression bomb protection disabled and applies thePOST /targetslimit, with tests for both APIs which run against real Vuforia.Contrary to the issue, the Query API's 30000 limits were never dead code — the existing
test_max_heightandtest_max_widthreach them against real Vuforia with 30001x1 and 1x30001 — and they are now reachable for square images too.This also fixes an unrelated pre-existing
ZeroDivisionErrorraised when rating an image of a single color, which the new tests need in order to make a small file with many pixels; say the word and I will split it out.🤖 Generated with Claude Code