mirror of
https://github.com/open-webui/open-webui.git
synced 2026-11-27 23:59:20 -05:00
* perf(users): drop redundant get_user_by_id refetch in session-user endpoints Five /user/* handlers refetched the user row via Users.get_user_by_id(user.id) immediately after receiving an identical UserModel from Depends(get_verified_user). Since get_verified_user already populated the user within the same request microseconds earlier, the refetch is pure overhead. The dead else branches (unreachable — get_verified_user raises 401 on missing user) are removed as a natural consequence. Affected endpoints: - GET /user/settings - GET /user/status - POST /user/status/update - GET /user/info - POST /user/info/update Eliminates one SELECT per request to each of these endpoints with no behavioral change. * fix(users): preserve USER_NOT_FOUND error on status update failure update_user_status_by_id returns None when the target user is missing or the update raises. The previous commit removed the pre-update existence gate (get_user_by_id) and returned the update result directly, which turned not-found/failure cases into 200 OK with a null body instead of the expected 400 USER_NOT_FOUND. Guard the update result explicitly to preserve the original API contract, matching the equivalent pattern already applied in /user/info/update. * docs(users): note lost-update tradeoff on /user/info/update Make the concurrency tradeoff explicit: merging against the auth-time snapshot slightly widens the lost-update window compared to the previous pre-merge refetch, but the refetch only narrowed (did not eliminate) that window. Real safety requires row locking or a version column. --------- Co-authored-by: Claude <noreply@anthropic.com>