BA
Better Auth•2w ago
chris

loging the stack; "payload" argument must be of type object.

I am unable to register new users with my better auth/prisma NextJS app. When a user submits valid credentials, I get this error:
2025-02-20T20:33:11.442Z ERROR [Better Auth]: TypeError [TypeError: The "payload" argument must be of type object. Received null] {
code: 'ERR_INVALID_ARG_TYPE'
}
2025-02-20T20:33:11.442Z ERROR [Better Auth]: TypeError [TypeError: The "payload" argument must be of type object. Received null] {
code: 'ERR_INVALID_ARG_TYPE'
}
Ideally we would have access to log the error .stack, is there a way to do this ?
7 Replies
bekacru
bekacru•2w ago
this usually happens when your schema doesn't match with what better auth expects. If you haven't, use the cli to generate the schema and cross check your field with the docs.
chris
chrisOP•2w ago
right, that is what i have been doing. it just bit me more than a few times, and a better error would be nice (for example so i know what schema is not correct) @bekacru but i understand how that might not be possible, some sort of onError function for the server side
bekacru
bekacru•2w ago
The error is thrown from prisma. It's more of their issue 👀
chris
chrisOP•2w ago
just thinking out loud here.. When I work with prisma directly, I can get better errors by logging the error stack
try {
await prisma.member.delete({ where: { id: 1 } });
} catch (error) {
console.log(error) // Useless message
console.error(error.stack); // Helpful details
}
try {
await prisma.member.delete({ where: { id: 1 } });
} catch (error) {
console.log(error) // Useless message
console.error(error.stack); // Helpful details
}
This pattern is basically required to debug Prism apps. How can I configure better auth to log the error stack in these cases so I can see the necessary information @bekacru
bekacru
bekacru•2w ago
maybe by changing the logger? you can pass logger in your auth config
lonelyplanet
lonelyplanet•2w ago
@chris add DEBUG="prisma*" to your env i had almost the same error, first log message told me i had a env issue with my db connection string

Did you find this page helpful?