From 8fbe8f03a552f7af4e69178d0f84844969050601 Mon Sep 17 00:00:00 2001 From: Danny Date: Tue, 22 Jul 2025 18:09:03 +1200 Subject: [PATCH] chore: model name needs to be default name (#3538) I was mistaken a [previous fix](https://github.com/better-auth/better-auth/commit/452069aed976f3f06bd3f94d0d51cc74449ad9e3), it just moved the error. This value should be the default model name to match [transformInput](https://github.com/better-auth/better-auth/blob/76c90f2e59b99c6d84b30ca0d3bc82cc0644ef2f/packages/better-auth/src/adapters/create-adapter/index.ts#L324) schema lookup. The schema looks like this ``` { ... rateLimit: { modelName: 'rateLimits', fields: { key: [Object], count: [Object], lastRequest: [Object], id: [Object] } } } ``` Matching on the default name returns the correct schema. This test is now passing locally a different rateLimiter model. ``` it ( "should hit rate limit on forth login attempt within 10s", async () => { for ( let i = 0; i < 3; i++ ) { const response = await request( testApp ) .post( usernameSignInPath ) .send( { username: testUsername, password: testPassword } ); expect( response.statusCode ).toEqual( 200 ); } const res = await request( testApp ) .post( usernameSignInPath ) .send( { username: testUsername, password: testPassword } ); expect( res.statusCode ).toEqual( 429 ); expect( res.headers ).toHaveProperty( "x-retry-after" ); } ); ``` --- packages/better-auth/src/api/rate-limiter/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/better-auth/src/api/rate-limiter/index.ts b/packages/better-auth/src/api/rate-limiter/index.ts index 84c1af8417..39cf6bf151 100644 --- a/packages/better-auth/src/api/rate-limiter/index.ts +++ b/packages/better-auth/src/api/rate-limiter/index.ts @@ -35,7 +35,7 @@ function getRetryAfter(lastRequest: number, window: number) { } function createDBStorage(ctx: AuthContext) { - const model = ctx.options.rateLimit?.modelName || "rateLimit"; + const model = "rateLimit"; const db = ctx.adapter; return { get: async (key: string) => {