Output debug mode?
Is there any way to output more debugging stuff? I'm getting an error which is quite difficult to debug;
23 Replies
can you share here your auth config?
Of course!
I'm trying to get Better Auth using the existing auth tables for Directus, a headless CMS. Unfortunately, their auth isn't quite as well thought out, and they colocate their account stuff with their user table, which (amongst other things) means that they can't have multiple OAuth providers attached to the same account. So I have manually created the missing account and verification tables, and am remapping the users and sessions tables that already exist.
I'm just trying to get the sign up w/ email working as a proof of concept, but I'm running into the error when I try the
auth.api.signUpEmail()
method.Directus Docs
Authentication | Directus Docs
Explore our resources and powerful data engine to build your projects confidently.
If you're using drizzle, this error is thrown form drizzle rather than better auth
the error message is basically saying there is a missing column that better auth is trying to insert. And that column name is "undefined" which is weird
can you try to update to latest beta
pnpm i better-auth@beta
Ahh yeah, you're one hundred percent right, looks like it is a drizzle thing. And updating to the beta has resulted in a fun new error-
Looks like the type is wrong for one of the columns on the users table, but the only two are
date_created
and date_updated
, which are timestamp({ mode: 'string' })
.
mode should be date
better auth tries to insert
Date
objectNuts. Is there any way to coerce it? I don't think directus supports it being a Date.
if it's a pg database, use the builtin postgres adapter instead of drizzle from better auth side.
Thanks so much! I'll give that a shot.
Ok! That worked too. Now, it's returning
2025-04-13T00:04:21.563Z ERROR [Better Auth]: Failed to create user error: invalid input syntax for type uuid: "b7g00pstBsS5FGSuTitnYGpkIxe2RBzK"
. The id generated by BetterAuth likely doesn't jive with the uuid
PK. I can see the generateId
function that's being called as part of the create user flow is a pretty straightforward wrapper, is there any possibility that this could be extended to allow for uuid use?maybe https://www.better-auth.com/docs/concepts/database#id-generation ? no idea, but I was doing that just fine in 1.2.4, but now with 1.2.6 i'm facing that error too
Database | Better Auth
Learn how to use a database with Better Auth.
have you set
generateId
to false
?yes!
i downgraded to 1.2.4
and it's working again
could you try setting
advanced.database.generateId
to false
?
the location is changed for the api but for the time being the old option should still work. will take a lookohhh ok! I had
I think the docs are just a touch out of date,
generateId
has shifted to database
according to the intellisenseindeed!
now it's working on 1.2.6
thanks guys!
If
database
is an object, how do I pass the postgres pool? i.e.
I have it like this in my code and the error is the same: invalid input syntax for type uuid: "u6XxTs8GfIKTfKwi9RnA1ucC9fOsIJII"
on 1.2.6?
It should more look like this
Sorry, I was using 1.2.5 but when I changed to 1.2.6 now I get this error: null value in column "id" of relation "user" violates not-null constraint. BTW, the problem started when I added the "admin" plugin
if you're using drizzle make sure each id field has auto generate id from the database
thanks, that actually worked. This is how the IDs are generated in the Drizzle schema > id: uuid('id').primaryKey().$default(() => randomUUID()) 😄
Hot damn! It's at the very least inserted the dummy data in the user table in the db- I get . The account table is empty, but this is well and truly progress.