COCPORN
COCPORNā€¢3w ago

SOLVED: User error (Was: Strange PROD behavior with validation)

I am seeing some strange behavior in my prod environment:
Jan 18, 22:46:30
failure

A

messages:send_user_message_on_server
ArgumentValidationError: Value does not match validator.
Path: .persona_id
Value: null
Validator: v.id("nodes")
Jan 18, 22:46:30
failure

A

messages:send_user_message_on_server
ArgumentValidationError: Value does not match validator.
Path: .persona_id
Value: null
Validator: v.id("nodes")
But the schema is this:
args: {
chat_id: v.id('chats'),
content: v.object({
message: v.string()
}),
persona_id: v.optional(v.id('nodes')),
source_node_id: v.optional(v.id('nodes'))
},
args: {
chat_id: v.id('chats'),
content: v.object({
message: v.string()
}),
persona_id: v.optional(v.id('nodes')),
source_node_id: v.optional(v.id('nodes'))
},
How can this be? The screenshots are attached to show that the server environment has indeed picked up that the persona_id is optional. Also, the error message in chrome looks different than usual when there is a validation error. And the same code works in dev. The error usually includes the validation error in the Chrome-log. Also, this same code works in the dev-environment. The request: f82d394c049b7717
No description
No description
9 Replies
erquhart
erquhartā€¢3w ago
This likely comes down to expected code not being deployed. If you run npx convex deploy with your latest code, you also want to make sure the deploy succeeds. It will often fail with schema changes due to incompatible existing documents.
COCPORN
COCPORNOPā€¢3w ago
But if the schema didn't match it, would it not be reflected in the function call in the portal?
erquhart
erquhartā€¢3w ago
The error message difference you're observing is because dev pushes your errors to the client, but prod only pushes errors made with ConvexError to avoid security issues from unintended leaks in error messges. If you run npx convex deploy, what output do you get
COCPORN
COCPORNOPā€¢3w ago
our prod deployment unique-rabbit-469 serves traffic at:

PUBLIC_CONVEX_URL=https://unique-rabbit-469.convex.cloud

Make sure that your published client is configured with this URL (for instructions see https://docs.convex.dev/hosting)

? Do you want to push your code to your prod deployment unique-rabbit-469 now? Yes
āœ” Deployed Convex functions to https://unique-rabbit-469.convex.cloud
our prod deployment unique-rabbit-469 serves traffic at:

PUBLIC_CONVEX_URL=https://unique-rabbit-469.convex.cloud

Make sure that your published client is configured with this URL (for instructions see https://docs.convex.dev/hosting)

? Do you want to push your code to your prod deployment unique-rabbit-469 now? Yes
āœ” Deployed Convex functions to https://unique-rabbit-469.convex.cloud
lee
leeā€¢3w ago
The error is because null is a value, while undefined means the field doesn't exist at all (i.e. is undefined)
erquhart
erquhartā€¢3w ago
Ah the default args in the dashboard exclude optionals
COCPORN
COCPORNOPā€¢3w ago
OK, that makes sense. I will look at it. Thanks so much for the quick response! I would think I would have run into that issue about 1000 times previously.
erquhart
erquhartā€¢3w ago
nulls in js are the worst lol
COCPORN
COCPORNOPā€¢3w ago
Yeah, but I really should have this stuff down by now. šŸ˜„ Thanks so much, I am pretty sure I can find this in no time. Thanks, now it works!

Did you find this page helpful?