CodingWithJamal
CodingWithJamal14mo ago

Convex Argument Validtion Error?

> [CONVEX Q(projects:list)] ArgumentValidationError: Object is missing the required field `user_id`. Consider wrapping the field validator in `v.optional(...)` if this is expected.

Object: {}
Validator: v.object({user_id: v.string()})
> [CONVEX Q(projects:list)] ArgumentValidationError: Object is missing the required field `user_id`. Consider wrapping the field validator in `v.optional(...)` if this is expected.

Object: {}
Validator: v.object({user_id: v.string()})
I keep getting this error. Im not sure why?
export const list = query({
args: {
user_id: v.string(),
},
handler: async (ctx, { user_id }) => {
const user = await getUserWithId(ctx, user_id);

if (!user) return [];

const projects = [];

for (const id of user.projects) {
const project = await ctx.db.get(id);
if (project) {
projects.push(project);
}
}

return projects;
},
});
export const list = query({
args: {
user_id: v.string(),
},
handler: async (ctx, { user_id }) => {
const user = await getUserWithId(ctx, user_id);

if (!user) return [];

const projects = [];

for (const id of user.projects) {
const project = await ctx.db.get(id);
if (project) {
projects.push(project);
}
}

return projects;
},
});
3 Replies
CodingWithJamal
CodingWithJamalOP14mo ago
I keep getting this on convex dev builds but no type errros in my code so im not sure?
mikeysee
mikeysee14mo ago
sounds like a runtime error then @CodingWithJamal .. I would look at your client code where you are calling list then see if you are 100% passing in the required user_id and that value is not null or undefined
CodingWithJamal
CodingWithJamalOP14mo ago
I just realized im passing the user_id as props in nextjs from a server component so maybe its undefined until the props pass so i might need to check for that

Did you find this page helpful?