Skip to content

write-guard: want.rs mutators ignore zero-row matches #538

Description

@forkwright

Finding

update_want_status/delete_want/update_release/delete_release/update_have_status/delete_have (lines 192,225,292,308,367,377) execute single-row UPDATE/DELETE by id and return Ok(()) without checking rows_affected, so a call against a nonexistent/stale id silently no-ops — want.rs was missed by commit 29a97cc which routed every other repo module through require_affected() to map zero-row matches to NotFound.

Evidence

crates/apotheke/src/repo/want.rs:192,225,292,308,367,377. Surfaced by the 2026-07-03 deep-audit workflow (adversarially verified + Opus-judged).

Why this matters

Mutating a stale or nonexistent want/release/have id silently no-ops instead of surfacing an error, hiding data-consistency bugs from every caller of these repo methods.

Desired correction

Route all six mutators through super::require_affected() (as the swept sibling modules do) so a zero-row match returns DbError::NotFound; add the *_nonexistent_returns_not_found tests the other modules gained.

Done when: the defect's failure mode no longer reproduces and a regression test covers it.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions