From 15381b2c41218aa674838993d0c811f52dd2c48b Mon Sep 17 00:00:00 2001 From: avi Date: Fri, 18 Sep 2026 23:17:04 -0500 Subject: [PATCH] Commit upload session row before responding; client's follow-up GET raced the post-response commit into a 404 --- backend/shonar/api/v1/recordings.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backend/shonar/api/v1/recordings.py b/backend/shonar/api/v1/recordings.py index 65cfaa0..73a745a 100644 --- a/backend/shonar/api/v1/recordings.py +++ b/backend/shonar/api/v1/recordings.py @@ -86,7 +86,13 @@ async def create_upload(body: UploadSessionCreate, user: CurrentUser, session: S session, user.id, body.declared_mime_type, body.declared_size_bytes, body.title, body.client_recording_id, body.transcription_model, ) + # Commit BEFORE responding: FastAPI's get_session commits after the + # response is sent, and the desktop client GETs /uploads/{id} the + # instant it sees the 201 — an uncommitted row raced that follow-up + # into a 404 "Upload status failed" (seen live Sep 18). + await session.commit() except up.UploadError as e: + await session.rollback() raise HTTPException(e.status_code, e.message) from None return us