Cryptic undefined is not valid Convex value error
I'm running into this
Have tried adding a bunch of logging statements to catch the undefined values but I can't see where the issue is.
I can add console logs up to this point:
10 Replies
I'd really appreciate any pointers on what to look for. When I log pageProperties it just looks like a regular object, all values set
The mutation looks something like this:
And I'm able to call from this mutation without issues:
Can you show the source for
patchBlockPropertiesWithNewGridLayout
At a guess from the code you have here, there may be cases where it doesn't return any resultah yeah that's true. the code is a little spaghetti so also open to take input on how to make it more concise!
Ok yeah patch doesn't return anything https://docs.convex.dev/api/interfaces/server.GenericDatabaseWriter#patch
Interface: GenericDatabaseWriter | Convex Developer Hub
server.GenericDatabaseWriter
okay so I shouldn't do return? not sure where the issue is
the issue is
patchBlockPropertiesWithNewGridLayout
returns undefined, which you store in the results array. And Convex doesn't support return values that have arrays containing undefined. That's what your error message is sayingah now i get it! when i hover over the function definition I saw this which confused me:
okay so I guess I should just not return anything from the mutation? not sure what best practice is in this case
Best practice is to return what needs to be returned (i.e. what the caller needs). You could return nothing, or return
results.length
, or convert the undefineds to nulls and return [null, null, null]
amazing, it works now! thank you soooo much!!!
The error message sucks, filing to improve, sorry @David Alonso !