Convex schema is not enforced properly
[CONVEX M(orders:setOrderPaid)] [LOG] 'Received offer ID:' 'jn7d950h4v4zdnktjazswr4dnx7at5zv'
[handleSuccessfulPayment] Error: {
error: '[Request ID: aeb2fb84dd5d9e4d] Server Error\n' +
'Uncaught ConvexError: Invalid offer ID: No matching offer found\n' +
' at handler (../convex/orders.ts:51:6)\n',
sessionId: 'cs_test_b1lwARf9sSn9khOxZklQlhXdupKi0Ay9psU26Ug6sWzLLofV6dN3PmOyut',
timestamp: '2025-02-22T15:17:10.468Z'
}
when i try to finalize an order using stripe checkout i pass some metadata into the session.
i use this metadata to populate my order.
in local environment everything is smooth and works as expected.
when i run this function in my staging or production environment, the mutation do not run giving me above error.
i double checked and the schema is not enforced properly, some fields when i try to run the function inside convex dashboard are missing, and some are not recognized for these two environments, although everything is deployed using commands as suggested for vercel using nextjs.
i also double checked in the dashboard the existence of the offer, using the same id i passed into the metadata, it does exist in my offer table
i tried to normalize the ids, casting it, upgrading convex to latest version but nothing.
have someone experienced such a mission critical bug?
every help or insight would be greatly appreciated.
i can share mutation schema and more logs if this can help
thank you
3 Replies
Thanks for posting in <#1088161997662724167>.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.
- Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
- Use search.convex.dev to search Docs, Stack, and Discord all at once.
- Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI.
- Avoid tagging staff unless specifically instructed.
Thank you!
"Invalid offer ID: No matching offer found"
this looks like an error you throw in your code, can you console.log() the offer ID right before that to make sure it's what you think it is?
the schema is not enforced properly, some fields when i try to run the function inside convex dashboard are missingIf you check the history pane of the dashboard for this production deployment, do you see deploys from Vercel happening? Is this code actuallybeing updated?
i also double checked in the dashboard the existence of the offer, using the same id i passed into the metadata, it does exist in my offer tableGreat, sounds like adding a console.log right before this error should clear things up
Ehi Tom thanks for the advice, here's the log:
[handleSuccessfulPayment] Error: {
error: '[Request ID: 90d012bbf3a4135e] Server Error\n' +
'Uncaught Error: Failed to insert or update a document in table "orders" because it does not match the schema: Found ID "jn7d950h4v4zdnktjazswr4dnx7at5zv" from table
orders
, which does not match the table name in validator v.id("offers")
.Path: .offerId\n' +
' at async handler (../convex/orders.ts:99:15)\n',
sessionId: 'cs_test_b1rbrBXXJU78vqp2800snAd4IKyQ9PJehibAgPdkyvzPx9IXXJAQ10p0fO',
offerId: 'jn7d950h4v4zdnktjazswr4dnx7at5zv',
timestamp: '2025-02-23T23:30:04.551Z'
}
the error is thrown from the catch block in convex order.ts mutation
i deleted all the orders from all my dev environments to catch any possible duplications or discrepancies.
the situation is pretty strange because:
my local environment is "perfect" it receive every right clean data timely and correctly.
my staging and prod environments are getting all the data but not the orders related ones.
one very puzzling thing is that if i remove all the validations from schema and mutations,to forcely write the data without checking types, the order from staging comes in, but is stored in my local environment order table.
yes you read correctly.
i can give you screenshot and paste snippets
thanks again for your time
@Tom never mind solved, was stripe webhooks issue sorry to have bothered you with unrelated issue