BUG: POST /assets/:id/mark-empty requires status=live — but capture shutdown may pass wrong assetId #66

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

Fixed — POST /:id/mark-empty now reads the asset's current status first, no-ops idempotently when already terminal (error/ready), accepts both live and processing (handles the capture-shutdown race), and returns 409 with the offending status for any other state. See services/mam-api/src/routes/assets.js:347-376.

Fixed — `POST /:id/mark-empty` now reads the asset's current status first, no-ops idempotently when already terminal (`error`/`ready`), accepts both `live` and `processing` (handles the capture-shutdown race), and returns 409 with the offending status for any other state. See `services/mam-api/src/routes/assets.js:347-376`.
Author
Owner

Fix Plan — #66 mark-empty requires status=live but capture may crash first

Root cause: Two scenarios: (1) capture container crashes before calling mark-empty, asset stays status=live forever; (2) asset_id passed to capture container may not match.

Fix — add automatic cleanup to scheduler tick:

// In scheduler.js tick:
await pool.query(
  `UPDATE assets SET status = 'error', error = 'Capture timeout'
   WHERE status = 'live' AND created_at < NOW() - INTERVAL '30 minutes'`
);

Also: ensure capture container always calls mark-empty on shutdown (SIGTERM handler in capture).

Files: src/scheduler.js, capture service
Effort: ~1h
**Priority: P2 — stale state cleanup

## Fix Plan — #66 mark-empty requires status=live but capture may crash first **Root cause:** Two scenarios: (1) capture container crashes before calling mark-empty, asset stays status=live forever; (2) asset_id passed to capture container may not match. **Fix — add automatic cleanup to scheduler tick:** ```js // In scheduler.js tick: await pool.query( `UPDATE assets SET status = 'error', error = 'Capture timeout' WHERE status = 'live' AND created_at < NOW() - INTERVAL '30 minutes'` ); ``` Also: ensure capture container always calls mark-empty on shutdown (SIGTERM handler in capture). **Files:** src/scheduler.js, capture service **Effort:** ~1h **Priority: P2 — stale state cleanup
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#66
No description provided.