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

Warning

Review limit reached

@plind-junior, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 57 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 49246d99-3f60-4fdf-a4d7-7debd64570cd

📥 Commits

Reviewing files that changed from the base of the PR and between 4de2b66 and dd2990a.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • src/vouch/proposals.py
  • tests/test_storage.py
✨ 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
@plind-junior

Copy link
Copy Markdown
Member

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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.

2 participants