[PR #6894] [MERGED] fix(update-user): breaks during stateless auth #15197

Closed
opened 2026-04-13 09:53:01 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/6894
Author: @ping-maxwell
Created: 12/20/2025
Status: Merged
Merged: 12/20/2025
Merged by: @Bekacru

Base: canaryHead: fix/update-user/breaks-during-state-less-auth


📝 Commits (3)

  • 20adaff fix(update-user): breaks during state-less auth
  • fa6e1df Merge branch 'canary' into fix/update-user/breaks-during-state-less-auth
  • b27838c Update packages/better-auth/src/api/routes/update-user.ts

📊 Changes

1 file changed (+13 additions, -1 deletions)

View changed files

📝 packages/better-auth/src/api/routes/update-user.ts (+13 -1)

📄 Description

It's possible that the internalAdapter.updateUser to return null during stateless auth, which can break things unexpectedly.

This PR is just a patch for this specific issue where if updateUser does return null, we manually assemble the correctly updated user object to send to setSessionCookie

Also added a check at the start to ensure users can't pass an array as the body.


Summary by cubic

Fixes the update-user route so it no longer breaks in stateless auth when internalAdapter.updateUser returns null. We now build the updated user from the session + submitted fields and set it in the session cookie.

  • Bug Fixes
    • Validate request body: must be an object, not an array.
    • Construct updatedUser from session.user when updateUser returns null.
    • Use updatedUser when calling setSessionCookie.

Written for commit b27838c819. Summary will update automatically on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/6894 **Author:** [@ping-maxwell](https://github.com/ping-maxwell) **Created:** 12/20/2025 **Status:** ✅ Merged **Merged:** 12/20/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `fix/update-user/breaks-during-state-less-auth` --- ### 📝 Commits (3) - [`20adaff`](https://github.com/better-auth/better-auth/commit/20adaffd1342f3834dcc164b1809624737fe864e) fix(update-user): breaks during state-less auth - [`fa6e1df`](https://github.com/better-auth/better-auth/commit/fa6e1df7e864e242725bcd2ed6fa9438ba278a5b) Merge branch 'canary' into fix/update-user/breaks-during-state-less-auth - [`b27838c`](https://github.com/better-auth/better-auth/commit/b27838c819b66343d890e191d729df1a7b6ca727) Update packages/better-auth/src/api/routes/update-user.ts ### 📊 Changes **1 file changed** (+13 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/routes/update-user.ts` (+13 -1) </details> ### 📄 Description It's possible that the `internalAdapter.updateUser` to return null during stateless auth, which can break things unexpectedly. This PR is just a patch for this specific issue where if `updateUser` does return null, we manually assemble the correctly updated user object to send to `setSessionCookie` Also added a check at the start to ensure users can't pass an array as the body. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixes the update-user route so it no longer breaks in stateless auth when internalAdapter.updateUser returns null. We now build the updated user from the session + submitted fields and set it in the session cookie. - **Bug Fixes** - Validate request body: must be an object, not an array. - Construct updatedUser from session.user when updateUser returns null. - Use updatedUser when calling setSessionCookie. <sup>Written for commit b27838c819b66343d890e191d729df1a7b6ca727. Summary will update automatically on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-13 09:53:01 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#15197