Skip to content

feat(snapshots): Add 40M pixel limit validation for snapshot images#3179

Merged
NicoHinderling merged 4 commits intomasterfrom
feat/snapshot-pixel-limit
Mar 4, 2026
Merged

feat(snapshots): Add 40M pixel limit validation for snapshot images#3179
NicoHinderling merged 4 commits intomasterfrom
feat/snapshot-pixel-limit

Conversation

@NicoHinderling
Copy link
Copy Markdown
Contributor

@NicoHinderling NicoHinderling commented Mar 3, 2026

The backend enforces a 40M pixel limit per image during snapshot comparison
(MAX_DIFF_PIXELS), but oversized images were only rejected at comparison
time, wasting upload bandwidth. The CLI now checks width * height against
the 40,000,000 pixel threshold before uploading and reports all violations
with their dimensions.

Refs EME-885

Validate image pixel counts before uploading to catch oversized images
early, matching the backend's MAX_DIFF_PIXELS limit. Images exceeding
40,000,000 pixels are reported with their dimensions and the command
fails before wasting bandwidth on uploads that would be rejected.

Refs EME-885
Co-Authored-By: Claude <noreply@anthropic.com>
@linear
Copy link
Copy Markdown

linear bot commented Mar 3, 2026

@github-actions

This comment was marked as resolved.

Cover passing, boundary, single violation, multiple violations,
and empty input cases for validate_image_sizes.

Co-Authored-By: Claude <noreply@anthropic.com>
@NicoHinderling NicoHinderling force-pushed the feat/snapshot-pixel-limit branch from e2d79c4 to 3d06806 Compare March 3, 2026 19:24
@NicoHinderling NicoHinderling marked this pull request as ready for review March 3, 2026 19:24
@NicoHinderling NicoHinderling requested review from a team and szokeasaurusrex as code owners March 3, 2026 19:24
@NicoHinderling NicoHinderling force-pushed the feat/snapshot-pixel-limit branch from 1c4e2b5 to 3d06806 Compare March 3, 2026 19:27
@NicoHinderling
Copy link
Copy Markdown
Contributor Author

actually not going to bother w a changelog since we're actively developing a feature that isn't available yet, so sharing about feature changes for it doesn't really make sense

@NicoHinderling NicoHinderling changed the title feat(snapshots): Add 40M pixel limit validation for snapshot images feat(snapshots): Add pixel limit validation and retention-based expiration Mar 3, 2026
@NicoHinderling NicoHinderling changed the title feat(snapshots): Add pixel limit validation and retention-based expiration feat(snapshots): Add 40M pixel limit validation for snapshot images Mar 3, 2026
@NicoHinderling NicoHinderling force-pushed the feat/snapshot-pixel-limit branch from dcc24dd to 3d06806 Compare March 3, 2026 19:54
@NicoHinderling NicoHinderling added the skip-changelog Apply this label to PRs that do not contain any user-facing changes label Mar 3, 2026
})
}

fn validate_image_sizes(images: &[ImageInfo]) -> Result<()> {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just do this inline on line 161 and return None/error log if the size is larger than 40M?

Copy link
Copy Markdown
Contributor Author

@NicoHinderling NicoHinderling Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The separate validate_image_sizes function is intentional. It collects and reports ALL oversized images in a single error message, so the user sees every violation at once.

Inlining with return None would silently skip oversized images and produce an incomplete snapshot without a hard failure.

We want to fail loudly here rather than let users unknowingly upload partial snapshots.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping the separate validation function intentionally — it collects ALL violations and reports them in a single error message, so the user sees every oversized image at once rather than discovering them one-by-one. The reviewer's refactoring commit (4ec1b22) already refined this function with the cleaner peekable iterator approach.

  • Claude Code

Copy link
Copy Markdown
Member

@szokeasaurusrex szokeasaurusrex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm, see comment for how we might improve readability a bit

Co-authored-by: Daniel Szoke <7881302+szokeasaurusrex@users.noreply.github.com>
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

…x test assertion

The reviewer's refactoring commit used img.pixels() and .join() but
didn't include the ImageInfo::pixels() impl block or the itertools
import. Also fixes the test assertion string to match the updated error
message wording.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@NicoHinderling NicoHinderling enabled auto-merge (squash) March 4, 2026 16:47
@NicoHinderling NicoHinderling merged commit f3e45e8 into master Mar 4, 2026
25 checks passed
@NicoHinderling NicoHinderling deleted the feat/snapshot-pixel-limit branch March 4, 2026 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-changelog Apply this label to PRs that do not contain any user-facing changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants