Incorrect invalid type error?
When I try to exectute the following code in a convex function:
I get the following error:
It works fine if I do the following:
NOTE: I'm using a promise.all above in the way as I am as a minimal example, in real life its an endpoint that takes a variable length vaccine list.
export const updateAnimalVaccineList = mutationWithTriggers({
handler: async (ctx, args) => {
return await Promise.all(
[
{
expirationDate: "2028-07-25",
id: "n571fm2daz2w33w1mjqjbz812d7ts71p",
name: "Slovenian Chia Seeds Soup",
},
].map(({ id, ...rest }) => {
return ctx.db.patch(id as Id<"vaccines">, rest)
}),
)
},
})export const updateAnimalVaccineList = mutationWithTriggers({
handler: async (ctx, args) => {
return await Promise.all(
[
{
expirationDate: "2028-07-25",
id: "n571fm2daz2w33w1mjqjbz812d7ts71p",
name: "Slovenian Chia Seeds Soup",
},
].map(({ id, ...rest }) => {
return ctx.db.patch(id as Id<"vaccines">, rest)
}),
)
},
})I get the following error:
CONVEX M(vaccines:updateAnimalVaccineList)] [Request ID: 0ea6c4ad70528400] Server Error
Uncaught Error: undefined is not a valid Convex value (present at path [0] in original object ["undefined"]). To learn about Convex's supported types, see https://docs.convex.dev/using/types.
at convexToJsonInternal (../../node_modules/convex/src/values/value.ts:300:6)
at <anonymous> (../../node_modules/convex/src/values/value.ts:335:4)
at map [as map] (<anonymous>)
at convexToJsonInternal (../../node_modules/convex/src/values/value.ts:333:29)
at convexToJson (../../node_modules/convex/src/values/value.ts:430:0)CONVEX M(vaccines:updateAnimalVaccineList)] [Request ID: 0ea6c4ad70528400] Server Error
Uncaught Error: undefined is not a valid Convex value (present at path [0] in original object ["undefined"]). To learn about Convex's supported types, see https://docs.convex.dev/using/types.
at convexToJsonInternal (../../node_modules/convex/src/values/value.ts:300:6)
at <anonymous> (../../node_modules/convex/src/values/value.ts:335:4)
at map [as map] (<anonymous>)
at convexToJsonInternal (../../node_modules/convex/src/values/value.ts:333:29)
at convexToJson (../../node_modules/convex/src/values/value.ts:430:0)It works fine if I do the following:
export const updateAnimalVaccineList = mutationWithTriggers({
handler: async (ctx, args) => {
return await ctx.db.patch("n571fm2daz2w33w1mjqjbz812d7ts71p" as Id<"vaccines">, {
expirationDate: "2028-07-25",
name: "Slovenian Chia Seeds Soup",
})
// return await Promise.all(
// [
// {
// expirationDate: "2028-07-25",
// id: "n571fm2daz2w33w1mjqjbz812d7ts71p",
// name: "Slovenian Chia Seeds Soup",
// },
// ].map(({ id, ...rest }) => {
// return ctx.db.patch(id as Id<"vaccines">, rest)
// }),
// )
},
})export const updateAnimalVaccineList = mutationWithTriggers({
handler: async (ctx, args) => {
return await ctx.db.patch("n571fm2daz2w33w1mjqjbz812d7ts71p" as Id<"vaccines">, {
expirationDate: "2028-07-25",
name: "Slovenian Chia Seeds Soup",
})
// return await Promise.all(
// [
// {
// expirationDate: "2028-07-25",
// id: "n571fm2daz2w33w1mjqjbz812d7ts71p",
// name: "Slovenian Chia Seeds Soup",
// },
// ].map(({ id, ...rest }) => {
// return ctx.db.patch(id as Id<"vaccines">, rest)
// }),
// )
},
})NOTE: I'm using a promise.all above in the way as I am as a minimal example, in real life its an endpoint that takes a variable length vaccine list.
