New Release Causes: `Field user_id not found in model member`

Hello, I updated from better auth 1.2.5 to 1.2.6 and now when I call the following:
const organizations = await Promise.try(() =>
auth.api.listOrganizations({
headers: request.headers,
}),
).catch((error) => {
console.error(error);
return [];
});
const organizations = await Promise.try(() =>
auth.api.listOrganizations({
headers: request.headers,
}),
).catch((error) => {
console.error(error);
return [];
});
I see the following trace:
→ Error: Field user_id not found in model member
at getDefaultFieldName (file:///Users/kenny/workspace/firestorm/node_modules/better-auth/dist/shared/better-auth.Bz1paiXf.mjs:79:13)
at getFieldName (file:///Users/kenny/workspace/firestorm/node_modules/better-auth/dist/shared/better-...
→ Error: Field user_id not found in model member
at getDefaultFieldName (file:///Users/kenny/workspace/firestorm/node_modules/better-auth/dist/shared/better-auth.Bz1paiXf.mjs:79:13)
at getFieldName (file:///Users/kenny/workspace/firestorm/node_modules/better-auth/dist/shared/better-...
When reverted back to 1.2.5 and it works fine.
12 Replies
Kenny
KennyOP2w ago
import { betterAuth } from "better-auth";
import { organization } from "better-auth/plugins";
import { D1Dialect } from "kysely-d1";

export function serverAuth(db: FirestormDatabase, env: Env) {
const auth = betterAuth({
database: new D1Dialect({ database: env.FIRESTORM_DB }),
user: {
modelName: "firestorm_users",
fields: { /* ... basic user fields ... */ },
},
session: {
modelName: "firestorm_sessions",
fields: {
userId: "user_id",
activeOrganizationId: "active_organization_id",
// ... other session fields
},
},
plugins: [
organization({
schema: {
organization: {
modelName: "firestorm_organizations",
fields: { /* ... */ },
},
member: { // <--- Relevant to error
modelName: "firestorm_members",
fields: {
userId: "user_id", // Error source?
organizationId: "organization_id",
createdAt: "created_at",
},
},
// Other schemas omitted
},
// Other org plugin config omitted
}),
// Other plugins omitted
],
// Other config omitted
});
return auth;
}
import { betterAuth } from "better-auth";
import { organization } from "better-auth/plugins";
import { D1Dialect } from "kysely-d1";

export function serverAuth(db: FirestormDatabase, env: Env) {
const auth = betterAuth({
database: new D1Dialect({ database: env.FIRESTORM_DB }),
user: {
modelName: "firestorm_users",
fields: { /* ... basic user fields ... */ },
},
session: {
modelName: "firestorm_sessions",
fields: {
userId: "user_id",
activeOrganizationId: "active_organization_id",
// ... other session fields
},
},
plugins: [
organization({
schema: {
organization: {
modelName: "firestorm_organizations",
fields: { /* ... */ },
},
member: { // <--- Relevant to error
modelName: "firestorm_members",
fields: {
userId: "user_id", // Error source?
organizationId: "organization_id",
createdAt: "created_at",
},
},
// Other schemas omitted
},
// Other org plugin config omitted
}),
// Other plugins omitted
],
// Other config omitted
});
return auth;
}
bump
bekacru
bekacru2w ago
taking a look
Kenny
KennyOP2w ago
appreciate it!
bekacru
bekacru2w ago
could you try pnpm i https://pkg.pr.new/better-auth/better-auth@2245
Kenny
KennyOP2w ago
yep works for me imma clear all cache to be sure cleared cache and still works
bekacru
bekacru2w ago
will publish a patch soon thanks!
Kenny
KennyOP2w ago
of course!
Siarhei Bautrukevich
Hey guys, have a problem with a verification table SERVER_ERROR: Error: Field expires_at not found in model verification at getDefaultFieldName (file:///app/node_modules/.pnpm/[email protected]/node_modules/better-auth/dist/shared/better-auth.Bz1paiXf.mjs:79:13) verification: { modelName: "auth_verifications", fields: { expiresAt: "expires_at", createdAt: "created_at", updatedAt: "updated_at", }, }, Its a same bug? Even in 1.2.5
Kenny
KennyOP2w ago
hm, I have never received that. What operation causes it?
Enzo 文字Yakisobi何でも
Take a look at your lock file If you simple updated to 1.2.6 and then downgraded to 1.2.5 Some depencies will be messed up, I guess
bekacru
bekacru7d ago
try toupgrade 1.2.7-beta.1 and let me know if it is still an issue

Did you find this page helpful?