BUG: POST /assets with status=live asset already existing: captures registered as processing overwrite the live asset #63

Closed
opened 2026-05-25 03:22:04 -04:00 by zgaetano · 1 comment
Owner

Fixed in migration 017-live-asset-unique-index.sql — partial unique index on (project_id, display_name) WHERE status='live' prevents the silent overwrite. The INSERT now fails with a 409-style unique-constraint violation when two captures collide.

Fixed in migration `017-live-asset-unique-index.sql` — partial unique index on `(project_id, display_name) WHERE status='live'` prevents the silent overwrite. The INSERT now fails with a 409-style unique-constraint violation when two captures collide.
Author
Owner

Fix Plan — #63 POST /assets race: processing overwrites live asset

Root cause: Two simultaneous captures for same projectId + clipName can both find the same live row and both UPDATE it. Second capture overwrites first S3 keys.

Fix — add partial unique index:

CREATE UNIQUE INDEX idx_live_unique ON assets (project_id, display_name) WHERE status = 'live';

This makes the second INSERT fail with a unique violation (caught as 409). The capture container should retry with a new clipName or wait.

Files: migration SQL, src/routes/assets.js POST handler
Effort: ~30min
**Priority: P2 — data integrity

## Fix Plan — #63 POST /assets race: processing overwrites live asset **Root cause:** Two simultaneous captures for same projectId + clipName can both find the same live row and both UPDATE it. Second capture overwrites first S3 keys. **Fix — add partial unique index:** ```sql CREATE UNIQUE INDEX idx_live_unique ON assets (project_id, display_name) WHERE status = 'live'; ``` This makes the second INSERT fail with a unique violation (caught as 409). The capture container should retry with a new clipName or wait. **Files:** migration SQL, src/routes/assets.js POST handler **Effort:** ~30min **Priority: P2 — data integrity
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: WildDragonLLC/dragonflight#63
No description provided.