[PR #6327] [MERGED] fix: handle potential null values in getCurrentAuthContext #23496

Closed
opened 2026-04-15 21:45:55 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/6327
Author: @himself65
Created: 11/26/2025
Status: Merged
Merged: 11/26/2025
Merged by: @himself65

Base: canaryHead: himself65/2025/11/26/fallback


📝 Commits (1)

  • 0bc9258 fix: handle potential null values in getCurrentAuthContext

📊 Changes

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

View changed files

📝 packages/better-auth/src/db/internal-adapter.ts (+4 -4)

📄 Description

Fixes: https://github.com/better-auth/better-auth/issues/6315


Summary by cubic

Gracefully handle missing or failing auth context in createInternalAdapter to prevent session creation crashes.

  • Bug Fixes
    • Wrap getCurrentAuthContext with catch(() => null).
    • Use optional chaining for ctx.request, ctx.headers, and ctx.context.options.
    • Add safe fallbacks for ipAddress and userAgent when headers are unavailable.

Written for commit 0bc9258ab0. 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/6327 **Author:** [@himself65](https://github.com/himself65) **Created:** 11/26/2025 **Status:** ✅ Merged **Merged:** 11/26/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `himself65/2025/11/26/fallback` --- ### 📝 Commits (1) - [`0bc9258`](https://github.com/better-auth/better-auth/commit/0bc9258ab0d0d083a8cbb0836059e1bd49d1c1bf) fix: handle potential null values in `getCurrentAuthContext` ### 📊 Changes **1 file changed** (+4 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/db/internal-adapter.ts` (+4 -4) </details> ### 📄 Description Fixes: https://github.com/better-auth/better-auth/issues/6315 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Gracefully handle missing or failing auth context in createInternalAdapter to prevent session creation crashes. - **Bug Fixes** - Wrap getCurrentAuthContext with catch(() => null). - Use optional chaining for ctx.request, ctx.headers, and ctx.context.options. - Add safe fallbacks for ipAddress and userAgent when headers are unavailable. <sup>Written for commit 0bc9258ab0d0d083a8cbb0836059e1bd49d1c1bf. 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-15 21:45:55 -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#23496