Sitruc
Sitruc9mo ago

ArgumentValidationError

I'm getting the following error
ArgumentValidationError: Object is missing the required field `userId`. Consider wrapping the field validator in `v.optional(...)` if this is expected.

Object: {}
Validator: v.object({userId: v.id("users")})
ArgumentValidationError: Object is missing the required field `userId`. Consider wrapping the field validator in `v.optional(...)` if this is expected.

Object: {}
Validator: v.object({userId: v.id("users")})
However I'm confused if this is refering to the handler or the schema itself. My handler looks like this which has the optional wrapped around the arg
export const get = query({
args: {
userId: v.optional(v.id('users')),
},
handler: async (ctx, args) => {
if (args.userId === undefined) {
return [];
}
return await ctx.table('tableName').filter((q) => q.eq(q.field('userId'), args.userId));
},
});
export const get = query({
args: {
userId: v.optional(v.id('users')),
},
handler: async (ctx, args) => {
if (args.userId === undefined) {
return [];
}
return await ctx.table('tableName').filter((q) => q.eq(q.field('userId'), args.userId));
},
});
2 Replies
Michal Srb
Michal Srb9mo ago
ArgumentValidationError so this is referring to the handler. I would guess that you have an older version of the code deployed - is npm run dev / npx convex dev running? Maybe it's blocked on an error (check your terminal).
Sitruc
SitrucOP9mo ago
ahh that might have been it. I've been running the backend locally with just convex dev command so forgot to switch over when trying on prod, thanks

Did you find this page helpful?