Date is not a supported Convex type in v.any() field.
Hey Convex Team! 👋🏽 👋🏽
We are trying to store the messages of an AI SDK chat in the following field:
messages: v.array(v.any())
When trying to insert the messages we get the following error:
Date "2025-05-13T12:03:51.916Z" is not a supported Convex type
An example of the input json is:
Why does convex try to parse the string into a date object and not just use a string when I specify `v.any()
?6 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!
Convex won't parse strings at all, if you're getting that error then your data includes a Date object. Looking at the AI SDK reference, there's a timestamp field on response objects that's of Date type, guessing that's what's throwing it: https://ai-sdk.dev/docs/reference/ai-sdk-core/generate-text
generateText
API Reference for generateText.
(find "date" on the page)
Thanks! Is there a way to avoid manually mapping date to string in the generic object before inserting to the convex v.any() field?
JSON.parse(JSON.stringify(input))
should workThanks for the help!