King Alastor
King Alastor
Explore posts from servers
BABetter Auth
Created by King Alastor on 2/27/2025 in #bug-reports
Better-auth cannot be set up using pg Pool and postgres
It seems somewhere in the code there's hardcoded user relation when trying to set up: database: new Pool({ connectionString: process.env.DATABASE_URL, }), tables: { user: "users", account: "account", session: "session", verification: "verification" }, re-mapping has no effect, you still get an error:
2025-02-27T20:29:35.974Z ERROR [Better Auth]: Better auth was unable to query your database.
Error: [error: relation "user" does not exist] {
length: 103,
severity: 'ERROR',
code: '42P01',
detail: undefined,
hint: undefined,
position: '15',
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'parse_relation.c',
line: '1452',
routine: 'parserOpenTable'
}
GET /api/auth/callback/google?state=MAMMsYQKDb35w4C1JT8jGjqf6NXPecCy&code=4%2F0AQSTgQF4TIZX_veUgaUBV0f5hQ_AkYIuNYRfKKQkeM49kg1oUnAozryq-X5hlGjCawOePg&scope=email+profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+openid&authuser=0&prompt=none 302 in 557ms
GET /api/auth/error?error=internal_server_error 200 in 68ms
2025-02-27T20:29:35.974Z ERROR [Better Auth]: Better auth was unable to query your database.
Error: [error: relation "user" does not exist] {
length: 103,
severity: 'ERROR',
code: '42P01',
detail: undefined,
hint: undefined,
position: '15',
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'parse_relation.c',
line: '1452',
routine: 'parserOpenTable'
}
GET /api/auth/callback/google?state=MAMMsYQKDb35w4C1JT8jGjqf6NXPecCy&code=4%2F0AQSTgQF4TIZX_veUgaUBV0f5hQ_AkYIuNYRfKKQkeM49kg1oUnAozryq-X5hlGjCawOePg&scope=email+profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+openid&authuser=0&prompt=none 302 in 557ms
GET /api/auth/error?error=internal_server_error 200 in 68ms
When you use the npx @better-auth/cli generate command, it generates a migration file with "user" table and "user" relations but you cannot create a user table in postgres, it's reserved word. But when trying to log in, it still looks for the user table, dismissing the remapping to "users" table in auth.ts user: { modelName: "users", this gives me error:
2025-02-27T21:22:31.581Z ERROR [Better Auth]: unable_to_create_user
2025-02-27T21:22:31.581Z ERROR [Better Auth]: unable_to_create_user
2 replies
BABetter Auth
Created by King Alastor on 2/27/2025 in #help
database: new Pool
No description
4 replies
BABetter Auth
Created by King Alastor on 2/3/2025 in #help
Argument `token` is missing.
Hey, has anyone managet to get better-auth working with Prisma? i'm migrating from Authjs (next auth) to better-auth and i used the npx @better-auth/cli generate as well to create the schema and everything but i keep getting this error, even though database is completely synced and prisma client is generated:
2025-02-03T17:37:38.779Z ERROR [Better Auth]:
Invalid `db[getModelName(model)].create()` invocation in
C:\TSProjects\metal-vault\.next\server\chunks\node_modules_better-auth_dist_d8816d._.js:2667:62

2664 if (!db[getModelName(model)]) {
2665 throw new __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$better$2d$auth$2f$dist$2f$chunk$2d$UNWCXKMP$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["BetterAuthError"](`Model ${model} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`);
2666 }
→ 2667 const result = await db[getModelName(model)].create({
data: {
id: "zaQ7MgVxGF3Tjt6j4s3N3RVxccavdpG0",
identifier: "gNXa4OG7LYTggzzvjqGAzh-2XG2axCFG",
value: "{\"callbackURL\":\"/\",\"codeVerifier\":\"nYca5-cBhdZBc-JhYybXGiSifmMpR7Dd67s4gHQ7JN7XfLSH8LNz2KU-F98czk0PBLcpG3ahXekkx0Jq-MI9JM-_epnoX5rbB0FxaeeaIedeur7p-XiekEYmgTSEztnE\",\"expiresAt\":1738604858735}",
expiresAt: new Date("2025-02-03T17:47:38.735Z"),
createdAt: new Date("2025-02-03T17:37:38.735Z"),
updatedAt: new Date("2025-02-03T17:37:38.735Z"),
+ token: String
},
select: undefined
})

Argument `token` is missing.
2025-02-03T17:37:38.779Z ERROR [Better Auth]:
Invalid `db[getModelName(model)].create()` invocation in
C:\TSProjects\metal-vault\.next\server\chunks\node_modules_better-auth_dist_d8816d._.js:2667:62

2664 if (!db[getModelName(model)]) {
2665 throw new __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$better$2d$auth$2f$dist$2f$chunk$2d$UNWCXKMP$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["BetterAuthError"](`Model ${model} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`);
2666 }
→ 2667 const result = await db[getModelName(model)].create({
data: {
id: "zaQ7MgVxGF3Tjt6j4s3N3RVxccavdpG0",
identifier: "gNXa4OG7LYTggzzvjqGAzh-2XG2axCFG",
value: "{\"callbackURL\":\"/\",\"codeVerifier\":\"nYca5-cBhdZBc-JhYybXGiSifmMpR7Dd67s4gHQ7JN7XfLSH8LNz2KU-F98czk0PBLcpG3ahXekkx0Jq-MI9JM-_epnoX5rbB0FxaeeaIedeur7p-XiekEYmgTSEztnE\",\"expiresAt\":1738604858735}",
expiresAt: new Date("2025-02-03T17:47:38.735Z"),
createdAt: new Date("2025-02-03T17:37:38.735Z"),
updatedAt: new Date("2025-02-03T17:37:38.735Z"),
+ token: String
},
select: undefined
})

Argument `token` is missing.
7 replies
PPrisma
Created by King Alastor on 1/23/2025 in #help-and-questions
Misleading error message: ERR_INVALID_ARG_TYPE
So i was trying to use raw sql but i forgot to account for @map values in my prisma schema so i was trying to update a column with the model name instead of the map name which i should have used in raw sql. However i ran into very weird error. The query itself was pretty simple:
await prisma.$executeRaw`
UPDATE "users"
SET "pending_actions" = array_remove(pending_actions, ${action})
WHERE id = ${userId}
`;
await prisma.$executeRaw`
UPDATE "users"
SET "pending_actions" = array_remove(pending_actions, ${action})
WHERE id = ${userId}
`;
however the error response i got was:
[TypeError: The "payload" argument must be of type object. Received null] {
code: 'ERR_INVALID_ARG_TYPE'
}
⨯ unhandledRejection: [TypeError: The "payload" argument must be of type object. Received null] {
code: 'ERR_INVALID_ARG_TYPE'
}
⨯ unhandledRejection: [TypeError: The "payload" argument must be of type object. Received null] {
code: 'ERR_INVALID_ARG_TYPE'
}
[TypeError: The "payload" argument must be of type object. Received null] {
code: 'ERR_INVALID_ARG_TYPE'
}
⨯ unhandledRejection: [TypeError: The "payload" argument must be of type object. Received null] {
code: 'ERR_INVALID_ARG_TYPE'
}
⨯ unhandledRejection: [TypeError: The "payload" argument must be of type object. Received null] {
code: 'ERR_INVALID_ARG_TYPE'
}
If you try to access a column in SQL IDE that doesn't exist, you get a simple error SQL Error [42703]: ERROR: column "testing" does not exist. I would have expected a similar error message to that if you're trying to update a table/user that doesn't exist. I solved the problem by modifying the table/col names to correct ones but it took me a while to notice that due to the error message implying that the variables i'm trying to pass down were null/undefined which was misleading. I don't really have a question since i solved the issues other than if it's intended or is this something that you'd need to update/fix or did i miss something?
3 replies