Skip to content

fix(apotheke): guard single-row writes against zero-row match - #507

Merged
forkwright merged 1 commit into
mainfrom
fix/apotheke-write-safety
Jul 2, 2026
Merged

fix(apotheke): guard single-row writes against zero-row match#507
forkwright merged 1 commit into
mainfrom
fix/apotheke-write-safety

Conversation

@forkwright

Copy link
Copy Markdown
Owner

Single-row UPDATE/DELETE repo functions across the media entities discarded the query result and returned Ok(()) even when zero rows matched — silently reporting success for a write against a missing target.

A shared require_affected(result, table, id) helper now maps a zero-row single-row write to DbError::NotFound (with a hex-rendered id). Applied uniformly across audiobook/book/comic/movie/music/news/podcast/quality/tv single-row writes (~28 sites), and the already-correct user/zone reference sites refactored onto the same helper. Per-entity *_nonexistent_returns_not_found tests added.

Gate: kanon gate --full green (fmt, check, clippy -D warnings --all-targets, nextest 1722/1722, deny, lint).

Closes #492

Single-row UPDATE/DELETE repo functions across the media entities discarded the
query result and returned Ok(()) even when zero rows matched, silently reporting
success for a write against a missing target. A shared require_affected() helper
now maps a zero-row single-row write to DbError::NotFound; applied uniformly
across audiobook/book/comic/movie/music/news/podcast/quality/tv (and the
reference user/zone sites refactored onto the same helper).

Closes #492

Gate-Passed: kanon 0.1.5 +stages:fmt,check,clippy,nextest,lint sha:6ec74a2270c964fc7753ad9086e2504f4174cfc7
@forkwright
forkwright merged commit 29a97cc into main Jul 2, 2026
12 checks passed
@forkwright
forkwright deleted the fix/apotheke-write-safety branch July 2, 2026 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Repo-wide: apotheke UPDATE/DELETE repo functions silently succeed on zero-row match

1 participant