[PR #3536] [MERGED] Bugfix: 500 error when setting rate limit storage with a different name #4872

Closed
opened 2026-03-13 12:02:40 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/3536
Author: @dkendrick
Created: 7/22/2025
Status: Merged
Merged: 7/22/2025
Merged by: @Bekacru

Base: mainHead: patch-1


📝 Commits (1)

  • f6f727f Bugfix: 500 error when setting rate limit storage with a different model name

📊 Changes

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

View changed files

📝 packages/better-auth/src/api/rate-limiter/index.ts (+2 -2)

📄 Description

The set function of createDbStorage is referencing a hardcoded string 'rateLimit'. This causes an error when a custom name for the model has been used:

TypeError: Cannot read properties of undefined (reading 'fields')

It should use the model the get method uses which reads modelName if it has been specified.

This change fixes the error locally for me.


Summary by cubic

Fixed a bug where setting rate limit storage with a custom model name caused a 500 error by ensuring the correct model name is used in database operations.


🔄 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/3536 **Author:** [@dkendrick](https://github.com/dkendrick) **Created:** 7/22/2025 **Status:** ✅ Merged **Merged:** 7/22/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `main` ← **Head:** `patch-1` --- ### 📝 Commits (1) - [`f6f727f`](https://github.com/better-auth/better-auth/commit/f6f727f3d95451fb2340f7f2c202dcfe75c35150) Bugfix: 500 error when setting rate limit storage with a different model name ### 📊 Changes **1 file changed** (+2 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/rate-limiter/index.ts` (+2 -2) </details> ### 📄 Description The `set` function of `createDbStorage` is referencing a hardcoded string 'rateLimit'. This causes an error when a custom name for the model has been used: ``` TypeError: Cannot read properties of undefined (reading 'fields') ``` It should use the model the `get` method uses which reads `modelName` if it has been specified. This change fixes the error locally for me. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixed a bug where setting rate limit storage with a custom model name caused a 500 error by ensuring the correct model name is used in database operations. <!-- 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 12:02:40 -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#4872