Skip to content

Respond to images with a huge number of pixels - #3410

Merged
adamtheturtle merged 2 commits into
mainfrom
adamtheturtle/vws-python-mock-issue-3378
Aug 10, 2026
Merged

Respond to images with a huge number of pixels#3410
adamtheturtle merged 2 commits into
mainfrom
adamtheturtle/vws-python-mock-issue-3378

Conversation

@adamtheturtle

Copy link
Copy Markdown
Member

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 DecompressionBombError rather than returning a response.

Verified against a real database: POST /targets returns ImageTooLarge above 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 the POST /targets limit, 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_height and test_max_width reach them against real Vuforia with 30001x1 and 1x30001 — and they are now reachable for square images too.

This also fixes an unrelated pre-existing 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; say the word and I will split it out.

🤖 Generated with Claude Code

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
adamtheturtle force-pushed the adamtheturtle/vws-python-mock-issue-3378 branch from 4a80c50 to 29a5f4b Compare August 10, 2026 16:28
…hon-mock-issue-3378

# Conflicts:
#	tests/mock_vws/test_query.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A large-dimension image raises an uncaught DecompressionBombError instead of returning a response

1 participant