Commit upload session row before responding; client's follow-up GET raced the post-response commit into a 404

This commit is contained in:
avi 2026-09-18 23:17:04 -05:00
commit 15381b2c41

View file

@ -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