Skip to content

fix(proposals): catch id collision in check_approvable batch precheck#470

Open
jaytbarimbao-collab wants to merge 1 commit into
vouchdev:testfrom
jaytbarimbao-collab:fix/check-approvable-id-collision
Open

fix(proposals): catch id collision in check_approvable batch precheck#470
jaytbarimbao-collab wants to merge 1 commit into
vouchdev:testfrom
jaytbarimbao-collab:fix/check-approvable-id-collision

Conversation

@jaytbarimbao-collab

Copy link
Copy Markdown

summary

approve() refuses to overwrite an artifact whose id already exists (guards against 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.

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_reason helper in src/vouch/proposals.py. 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 — the same exception approve() already carves out).

test plan

new regression test test_check_approvable_catches_id_collision_with_existing_claim in tests/test_storage.py: approves a claim with id foo-bar, files a second pending claim proposal with the same id, asserts check_approvable now returns a non-None "already exists" reason (fails on the old code — returns None), and that approve() still raises on it.

.venv/bin/python -m ruff check src tests
.venv/bin/python -m mypy src
.venv/bin/python -m pytest tests/ -q --ignore=tests/embeddings

all three clean.

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).
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: db163b92-0218-428b-bbb4-3db2910ba5b5

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added docs documentation, specs, examples, and repo guidance storage kb storage, migrations, schemas, and proposals tests tests and fixtures size: XS less than 50 changed non-doc lines labels Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs documentation, specs, examples, and repo guidance size: XS less than 50 changed non-doc lines storage kb storage, migrations, schemas, and proposals tests tests and fixtures

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant