Add input validation to Subject.set_color_depth - #384
Closed
snowplow-claude-review[bot] wants to merge 1 commit into
Closed
Conversation
…2fa691c78-snowplow-python-tracker-29740085620)
|
Thanks for your pull request. Is this your first contribution to a Snowplow open source project? Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://docs.snowplowanalytics.com/docs/contributing/contributor-license-agreement/ to learn more and sign. Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks. |
Matus Tomlein (matus-tomlein)
deleted the
loop/3a307af295a281a9ba70f6d2fa691c78-snowplow-python-tracker-29740085620
branch
July 27, 2026 07:51
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.
🤖 Draft implementation — refinement loop (3a307af295a281a9ba70f6d2fa691c78)
Drafted automatically by the Snowplow refinement loop (refine → product review → implement → review) from a Notion refinement, and opened here for a human to finish.
What the loop did
Add input validation to
Subject.set_color_depthWhat changed
Two files modified:
snowplow_tracker/subject.pygreater_than(depth, 0)as the first line ofset_color_depth, before the assignment toself.standard_nv_pairs["cd"].:type depth:annotation frominttoint,>0to match the sibling setters.greater_thanhelper was already imported; no new imports needed.snowplow_tracker/test/unit/test_subject.pytest_set_color_depth_rejects_non_positivewhich asserts thatset_color_depth(0)andset_color_depth(-1)each raiseValueError(viapytest.raises), and thatset_color_depth(1)succeeds.Why
set_screen_resolutionandset_viewportboth guard their numeric inputs withgreater_than;set_color_depthwas the only sibling setter without this guard. Zero and negative colour-depth values are nonsensical and should never reach the wire. This is a consistency fix with no wire-format or schema change — thecdfield itself is unchanged.Key decisions
greater_thanexactly — no bespoke validation logic. The helper already raisesValueErroron non-positive inputs, which is the repo's established contract.set_screen_resolutionandset_viewport.What to verify before merging
greater_than(depth, 0)is the correct call signature (checkcontracts.py— should match usage in sibling setters).test_subject.pysuite (pytest snowplow_tracker/test/unit/test_subject.py).0or a negative toset_color_depthintentionally (a quick repo-wide grep forset_color_depthis sufficient)../run-tests.sh).