[PR #6922] fix(session): add dev error logs when adapter join returns null user data #6968

Open
opened 2026-03-13 13:19:28 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/6922
Author: @tavongamatikiti
Created: 12/21/2025
Status: 🔄 Open

Base: canaryHead: fix/session-null-debugging


📝 Commits (1)

  • 46b893c fix(session): add dev error logs when adapter join returns null user data

📊 Changes

3 files changed (+86 additions, -1 deletions)

View changed files

📝 packages/better-auth/src/api/routes/session-api.test.ts (+59 -0)
📝 packages/better-auth/src/api/routes/session.ts (+15 -0)
📝 packages/better-auth/src/db/internal-adapter.ts (+12 -1)

📄 Description

Fix issue: client.getSession returned null, but session exist #6672- https://github.com/better-auth/better-auth/issues/6672


Summary by cubic

Improves session debugging in development by logging when the adapter returns a session without joined user data, and ensures getSession returns null in that case.

  • Bug Fixes

    • getSession now returns null when the adapter returns a session missing user join data.
    • Added a test for the broken join scenario.
  • New Features

    • Dev-only debug logs for null or expired sessions in getSession.
    • Dev-only error logs in internal adapter when user join data is missing, with guidance for adapter implementations.

Written for commit 46b893c26d. 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/6922 **Author:** [@tavongamatikiti](https://github.com/tavongamatikiti) **Created:** 12/21/2025 **Status:** 🔄 Open **Base:** `canary` ← **Head:** `fix/session-null-debugging` --- ### 📝 Commits (1) - [`46b893c`](https://github.com/better-auth/better-auth/commit/46b893c26d62652bfd59030651f08ebaa5c190a1) fix(session): add dev error logs when adapter join returns null user data ### 📊 Changes **3 files changed** (+86 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/routes/session-api.test.ts` (+59 -0) 📝 `packages/better-auth/src/api/routes/session.ts` (+15 -0) 📝 `packages/better-auth/src/db/internal-adapter.ts` (+12 -1) </details> ### 📄 Description Fix issue: client.getSession returned null, but session exist #6672- https://github.com/better-auth/better-auth/issues/6672 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Improves session debugging in development by logging when the adapter returns a session without joined user data, and ensures getSession returns null in that case. - **Bug Fixes** - getSession now returns null when the adapter returns a session missing user join data. - Added a test for the broken join scenario. - **New Features** - Dev-only debug logs for null or expired sessions in getSession. - Dev-only error logs in internal adapter when user join data is missing, with guidance for adapter implementations. <sup>Written for commit 46b893c26d62652bfd59030651f08ebaa5c190a1. 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-03-13 13:19:28 -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#6968