fix(proposals): catch id collision in check_approvable batch precheck#470
Open
jaytbarimbao-collab wants to merge 1 commit into
Open
Conversation
approve() refuses to overwrite an artifact whose id already exists (guards a crash-retry between put_<kind>() and move_proposal_to_decided silently rewriting it), but check_approvable -- the read-only precheck vouch approve a b uses to validate a whole batch before mutating anything -- never re-implemented that same guard. so a claim/entity/ relation proposal whose id collided with an existing artifact passed the precheck as approvable, then approve() raised on it anyway, breaking the documented all-or-nothing batch guarantee. factored the existing-artifact check into a shared, non-raising _existing_artifact_block_reason helper; approve()'s _ensure_no_ existing_artifact now delegates to it, and check_approvable calls the same helper for the same set of kinds (all but page and delete, same exception approve() already carves out).
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
summary
approve()refuses to overwrite an artifact whose id already exists (guards against a crash-retry betweenput_<kind>()andmove_proposal_to_decided()silently rewriting it), butcheck_approvable()— the read-only precheckvouch approve a buses to validate a whole batch before mutating anything — never re-implemented that same guard.what changed
so a claim/entity/relation proposal whose id collides with an existing artifact passes the precheck as approvable, then
approve()raises on it anyway — breaking the documented all-or-nothing batch guarantee (a typo or already-decided id is supposed to abort the whole batch before anything mutates; instead the batch can partially apply).factored the existing-artifact check into a shared, non-raising
_existing_artifact_block_reasonhelper insrc/vouch/proposals.py.approve()'s_ensure_no_existing_artifactnow delegates to it, andcheck_approvablecalls the same helper for the same set of kinds (all butpageanddelete— the same exceptionapprove()already carves out).test plan
new regression test
test_check_approvable_catches_id_collision_with_existing_claimintests/test_storage.py: approves a claim with idfoo-bar, files a second pending claim proposal with the same id, assertscheck_approvablenow returns a non-None "already exists" reason (fails on the old code — returnsNone), and thatapprove()still raises on it.all three clean.