fix(apotheke): guard want.rs and play_history single-row writes - #561
Merged
Conversation
…st zero-row match Six single-row UPDATE/DELETE mutators in want.rs (update_want_status, delete_want, update_release, delete_release, update_have_status, delete_have) and three in play_history/mod.rs (end_session, mark_scrobble_eligible, mark_scrobbled) discarded the query result and returned Ok(()) even when zero rows matched, silently reporting success for a write against a missing id/session. Route each through the shared require_affected() helper (established in 29a97cc) so a zero-row match returns DbError::NotFound instead. archon MonitorService::remove_want (the lost-approval want retraction) relies on delete_want being idempotent for an already-gone want, per the trait's documented invariant. Now that delete_want returns NotFound on a zero-row match, the retraction path maps NotFound to Ok(()) so retracting a non-existent want stays a no-op success; a normal caller still receives the stricter NotFound. Closes #538 Closes #552 Gate-Passed: kanon 0.1.5 +stages:fmt,check,clippy,nextest,lint sha:fa80c7dd3407dd71c11d8adc5590cb904af96b84
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.
Two write-guard-consistency gaps the 29a97cc sweep missed (deep-audit).
apotheke/src/repo/want.rs(update/delete want, release, have) now route throughrequire_affected, returningNotFoundon a zero-row match instead of a silentOk(()). Bulk writes untouched.play_history(end_session, mark_scrobble_eligible, mark_scrobbled) likewise.Reconciled with #560:
archon::remove_want(lost-approval want retraction) now mapsNotFound → Ok, preserving its documented idempotency invariant now thatdelete_wantis strict; normal callers still getNotFound.Gate green (1875 tests);
*_nonexistent_returns_not_foundtests added.Closes #538
Closes #552