Sync: reject duplicate positions before mutation #40

Closed
opened 2026-09-05 21:50:42 +00:00 by hermes · 1 comment
Owner

Context

Independent review found that duplicate remote track positions reach the SQLite membership constraint only after automatic matching has written beets associations. Sync then fails but leaves partial beets mutations, contrary to the fetch/validate-before-mutate rule in SPEC.md.

Task

Validate each fetched playlist's occurrence positions before opening or mutating plugin state, beets metadata, or playlistmanager contents. Reject duplicate positions with an actionable error naming the playlist and position.

Acceptance criteria

  • A regression test reproduces the partial-mutation path on current main.
  • Duplicate positions fail before any beets item write.
  • Plugin-state bytes and playlistmanager contents remain unchanged.
  • Valid ordered duplicate track occurrences at distinct positions continue to work.
## Context Independent review found that duplicate remote track positions reach the SQLite membership constraint only after automatic matching has written beets associations. Sync then fails but leaves partial beets mutations, contrary to the fetch/validate-before-mutate rule in `SPEC.md`. ## Task Validate each fetched playlist's occurrence positions before opening or mutating plugin state, beets metadata, or playlistmanager contents. Reject duplicate positions with an actionable error naming the playlist and position. ## Acceptance criteria - [ ] A regression test reproduces the partial-mutation path on current `main`. - [ ] Duplicate positions fail before any beets item write. - [ ] Plugin-state bytes and playlistmanager contents remain unchanged. - [ ] Valid ordered duplicate track occurrences at distinct positions continue to work.
Author
Owner

Completed in coop/beets-appleplaylists by implementation commit ed04e9d, merged through PR #41 as e4fbbffd4a0bf744d4967c6bfb03e4ffe369869a.

Duplicate positions are now rejected before any beets, plugin-state, or playlistmanager mutation. The regression test verifies all three stores remain unchanged; valid repeated tracks at distinct positions remain covered.

Validation: 104 tests passed with warnings promoted to errors, plus Ruff lint/format checks for these files, compileall, isolated CLI help, package build, and git diff --check.

Completed in `coop/beets-appleplaylists` by implementation commit `ed04e9d`, merged through PR #41 as `e4fbbffd4a0bf744d4967c6bfb03e4ffe369869a`. Duplicate positions are now rejected before any beets, plugin-state, or playlistmanager mutation. The regression test verifies all three stores remain unchanged; valid repeated tracks at distinct positions remain covered. Validation: 104 tests passed with warnings promoted to errors, plus Ruff lint/format checks for these files, compileall, isolated CLI help, package build, and `git diff --check`.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
coop/beets-appleplaylists#40
No description provided.