ianpaschal
CCConvex Community
•Created by ianpaschal on 4/6/2025 in #support-community
Help understanding 'Validator error: Expected ID for table...'
If you query a document with by an ID, if the ID exists on the table, you get the document back. If it doesn't, you get
null
.
However when testing, when I want to test that my function returns null (or throws a specific error) if the ID in the args is invalid, I instead get the error 'Validator error: Expected ID for table...'
What is the purpose of this error? And why does it behave differently? Shouldn't passing 'not_a_valid_foo_id' for an arg fooId
with type v.id('foos')
and then calling ctx.db.get(fooId)
just return null
and I can handle that as I like? Why does it throw an error?
Thanks in advance!9 replies
CCConvex Community
•Created by ianpaschal on 4/6/2025 in #support-community
getAuthUserId behaves oddly
In many of my functions, I use
const userId = await getAuthUserId(ctx);
to get the current user ID and check that it matches user IDs within requests. Works great!
To my surprise though, while testing, it stopped working. So I added const userIdentity = await ctx.auth.getUserIdentity()
and found that the value returned by getAuthUserId(ctx)
was actually equal to subject
rather than _id
. How come? Is getAuthUserId
first trying to get the ID and if it doesn't exist it returns the session? It can't always be using subject
otherwise none of my functions would be working.4 replies
CCConvex Community
•Created by ianpaschal on 3/14/2025 in #support-community
Sign in & sign up work on cloud dev, error on production
Hello all,
I've deployed my app via Vercel, and followed the set-up guy carefully using differerent env vars for dev and prod. I'm using Convex Auth.
My sign up and sign in flow seems to work perfectly when running on cloud dev. But on production, I'm getting the following errors:
When signing up:
Uncaught Error: Missing environment variable JWT_PRIVATE_KEY at requireEnv (../../node_modules/@convex-dev/auth/src/server/utils.ts:4:2)
However the authAccount and user records are created successfully.
So I tried signing in:
Uncaught Error: InvalidSecret at retrieveAccount (../../node_modules/@convex-dev/auth/src/server/implementation/index.ts:601:2)
Any idea what these mean?6 replies
CCConvex Community
•Created by ianpaschal on 2/25/2025 in #support-community
How to re-organize api structure?
It's neat that Convex automatically structures the
api
object according to your folders, files, and function names, but on a larger project it becomes a bit impractical. For example, I have convex/users/fetchCurrentUser.ts
with a function in there called, of course, fetchCurrentUser()
. However, in order to consume this, I have to use:
Is it possible to avoid this besides putting all functions in one file? That seems really impractical.6 replies
CCConvex Community
•Created by ianpaschal on 2/23/2025 in #support-community
Convex Auth: How to add custom data to signIn() (or up)
Hello all,
I'm trying to add additional fields to my sign up form which will be added to the users table. But I can't figure out how to pass them onward. Adding them to the FormData object passed to
signIn()
doesn't seem to work. How can one add these arbitrary fields (such as username
)? I could also make it optional, but it shouldn't be, every account should have a username. So I'd prefer to set it via the sign up process.
Any help much appreciated here. Also, would be happy to make a PR improving the documentation once I figure out how it's done. The documentation states:
You can only change fields to be required or add new required fields to the users table if all your authentication methods will provide those fields during sign-up (see how to do this for OAuth and Passwords).But the linked page there doesn't actually explain how to pass that data to
signIn()
when the user submits the form. And evidently the FormData is not the correct method.
Thanks for all help in advance!31 replies