From 158686aa0cdfc95857393e124129446d7772823f Mon Sep 17 00:00:00 2001 From: jigangz Date: Thu, 26 Mar 2026 22:06:37 -0700 Subject: [PATCH] fix: commit and refresh user after profile update in PATCH /auth/me The endpoint used db.flush() which writes to the DB transaction buffer but relies on the dependency cleanup to commit. If the response serialization happens before the commit, or if the session's expire_on_commit=False prevents refresh, the returned user object may not reflect the persisted state. This changes to explicit commit() + refresh() to ensure: 1. Changes are persisted immediately 2. The returned UserOut reflects the committed state 3. Server-side fields (updated_at) are properly populated Fixes #205 --- backend/app/api/auth.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/app/api/auth.py b/backend/app/api/auth.py index bf221945..1d9c7457 100644 --- a/backend/app/api/auth.py +++ b/backend/app/api/auth.py @@ -170,7 +170,8 @@ async def update_me( for field, value in update_data.items(): setattr(current_user, field, value) - await db.flush() + await db.commit() + await db.refresh(current_user) return UserOut.model_validate(current_user)