[PR #6954] [MERGED] fix: BETTER_AUTH_SECRET length check should not throw #6987

Closed
opened 2026-03-13 13:20:17 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/6954
Author: @Diabl0570
Created: 12/23/2025
Status: Merged
Merged: 12/23/2025
Merged by: @Bekacru

Base: canaryHead: fix/secret-length-check-should-not-throw


📝 Commits (3)

  • 750ae39 fix: BETTER_AUTH_SECRET length check should not throw
  • e537b6f chore: linter
  • 38fcd41 update unit test

📊 Changes

2 files changed (+25 additions, -12 deletions)

View changed files

📝 packages/better-auth/src/context/create-context.test.ts (+23 -10)
📝 packages/better-auth/src/context/create-context.ts (+2 -2)

📄 Description

In this MR: https://github.com/better-auth/better-auth/pull/6114 there is a check added that throws if the secret is <32 chars.

However for implementation currently running with a secret of <32 this now breaks the application.

I could also not find straight forward migration steps on how to rotate your secret.


Summary by cubic

Stop throwing when BETTER_AUTH_SECRET is shorter than 32 characters. We now log a warning to avoid breaking existing deployments while still encouraging stronger secrets.

  • Bug Fixes

    • validateSecret logs a warning instead of throwing when secret < 32.
    • Prevents startup failures in apps using shorter secrets.
  • Migration

    • Generate a 32+ char secret: npx @better-auth/cli secret or openssl rand -base64 32.
    • Update BETTER_AUTH_SECRET and restart; sessions signed with the old secret may require re-auth.

Written for commit 38fcd41562. 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/6954 **Author:** [@Diabl0570](https://github.com/Diabl0570) **Created:** 12/23/2025 **Status:** ✅ Merged **Merged:** 12/23/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `fix/secret-length-check-should-not-throw` --- ### 📝 Commits (3) - [`750ae39`](https://github.com/better-auth/better-auth/commit/750ae39c500ae2dd057f9cac6342d4b2a1ca2eef) fix: BETTER_AUTH_SECRET length check should not throw - [`e537b6f`](https://github.com/better-auth/better-auth/commit/e537b6fb68a6471f79deeb7ed0d9c1e939cd7459) chore: linter - [`38fcd41`](https://github.com/better-auth/better-auth/commit/38fcd41562b7b9c724704f924efd672607507912) update unit test ### 📊 Changes **2 files changed** (+25 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/context/create-context.test.ts` (+23 -10) 📝 `packages/better-auth/src/context/create-context.ts` (+2 -2) </details> ### 📄 Description In this MR: https://github.com/better-auth/better-auth/pull/6114 there is a check added that throws if the secret is <32 chars. However for implementation currently running with a secret of <32 this now breaks the application. I could also not find straight forward migration steps on how to rotate your secret. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Stop throwing when BETTER_AUTH_SECRET is shorter than 32 characters. We now log a warning to avoid breaking existing deployments while still encouraging stronger secrets. - **Bug Fixes** - validateSecret logs a warning instead of throwing when secret < 32. - Prevents startup failures in apps using shorter secrets. - **Migration** - Generate a 32+ char secret: npx @better-auth/cli secret or openssl rand -base64 32. - Update BETTER_AUTH_SECRET and restart; sessions signed with the old secret may require re-auth. <sup>Written for commit 38fcd41562b7b9c724704f924efd672607507912. 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:20:17 -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#6987