BlazeApleosB
Convex Community3mo ago
3 replies
BlazeApleos

ConvexAuth Uncaught Convex Error

🪲Bug Report🔑AuthAdvice
I'm trying to setup ConvexAuth and customize the validatePasswordRequirements. I'm copying the format in the example here, but I get this error:
[0] Hit error while running
auth:signIn
:
[0] Error [ConvexError]: [Request ID: 0d38fe217298c763] Server Error
[0] Uncaught ConvexError: INVALID_PASSWORD_PASSWORD_MISSING_NUMBER
[0] at validatePasswordRequirements [as validatePasswordRequirements] (../../convex/auth.ts:32:9)
...
[0] at validatePasswordRequirements [as validatePasswordRequirements] (../../convex/auth.ts:32:9) {
[0] data: 'INVALID_PASSWORD_PASSWORD_MISSING_NUMBER'
[0] }

It looks like the ConvexError is not communicated properly and is instead just a regular Error.

A really simplified example:
I throw this in my validation:
                if (!/\d/.test(password)) {
                    throw new ConvexError(INVALID_PASSWORD_PASSWORD_MISSING_NUMBER)
                }


I log this:
                        .catch((error: unknown) => {
                            if (error instanceof ConvexError) {
                                console.error('Error is a Convex Error')
                                console.error('Error: ', error.data)
                            } else {
                                console.error('Not a Convex Error')
                            }


It outputs:
Not a Convex Error


Am doing something obviously wrong? Is this not expected to work?
Thanks for your help!
GitHub
Library for built-in auth. Contribute to get-convex/convex-auth development by creating an account on GitHub.
convex-auth/test/src/auth/SignInWithPassword.tsx at main · get-con...
Was this page helpful?