BUG: PUT /sequences/:id/clips uses client.query('BEGIN') without error rollback on the inner INSERT loop #71
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Bug
PUT /sequences/:id/clipsinservices/mam-api/src/routes/sequences.js:190-215correctly uses BEGIN/COMMIT/ROLLBACK for the transaction. However, if the for-loop'sINSERTfor clip N+1 fails (e.g., FK violation on asset_id), the catch block executesROLLBACK— butnext(e)is called AFTER rollback. Thenext(e)sends a 500 to the client, which is correct.BUT: the sequence_check query at line 178 happens outside the transaction. Between that check and the BEGIN, another request could delete the sequence. The INSERT would then fail with a FK violation.
Impact
Location
services/mam-api/src/routes/sequences.js:178-215Fix
Move the existence check inside the transaction, or use
SELECT ... FOR UPDATEon the sequence row at the start.