ibrahimyaacob
ibrahimyaacob4mo ago

Do i have to re-write the validation again ??

i've been using this convex saas template and found this piece of code, the two thing is basically the same thing. I tried to refactor the mutation using schema.table.subscriptions.validator. The function compiles fine in the cloud, however when running the function im getting this error where my validator is just an empty object.
No description
No description
10 Replies
Hmza
Hmza4mo ago
the function you are getting failure on seems different then what you pointed. check subscriptions.ts /insertNewSubscription and see there's a field 'billingInterval' missing. you would be getting type safe errors there too.
ibrahimyaacob
ibrahimyaacobOP4mo ago
my code is correct, i just take different snapshot in different time else im getting type error in the first place
Hmza
Hmza4mo ago
so what and where exactly the error is ?
ibrahimyaacob
ibrahimyaacobOP4mo ago
No description
ibrahimyaacob
ibrahimyaacobOP4mo ago
here's the right one i previously use organizationSubscriptionValidator then im getting the object contains extra field error with this
ibrahimyaacob
ibrahimyaacobOP4mo ago
No description
Hmza
Hmza4mo ago
can you console log the args.organizationSubscription after line no 22 in handler to see why there's an extra field billingInterval and if this field is in your schema of convex for this table.
ibrahimyaacob
ibrahimyaacobOP4mo ago
it fails on args validation because its expecting empty object, like i shared in the image above
ian
ian4mo ago
You might check that there isn't an import cycle where it's undefined when the file is first parsed. that's my guess @ibrahimyaacob JavaScript does a funky thing with import cycles where it evaluates one of them with the other as undefined, then evaluates the other, then at runtime both are defined. But static-time definitions can end up storing undefined values, such as defining consts / args validators. You could try inlining that into your arg validator to test, or move it into its own file and import from there to see if that helps
ibrahimyaacob
ibrahimyaacobOP4mo ago
right now i end up replicating the validator (schema & args). i guess its fine for now. i trust you guys will fix this in the future

Did you find this page helpful?