Daniel Stoll
Daniel Stoll3w ago

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:
[
{
"role": "user",
"content": "...",
"id": "...",
"createdAt": "2025-05-13T12:03:42.185Z",
"parts": [
{
"type": "text",
"text": "..."
}
]
},
{
"role": "assistant",
"content": "...",
"id": "...",
"createdAt": "2025-05-13T12:03:51.916Z",
"reasoning": "undefined",
"toolInvocations": [],
"parts": [
{
"type": "step-start"
},
{
"type": "text",
"text": "..."
}
]
}
]
[
{
"role": "user",
"content": "...",
"id": "...",
"createdAt": "2025-05-13T12:03:42.185Z",
"parts": [
{
"type": "text",
"text": "..."
}
]
},
{
"role": "assistant",
"content": "...",
"id": "...",
"createdAt": "2025-05-13T12:03:51.916Z",
"reasoning": "undefined",
"toolInvocations": [],
"parts": [
{
"type": "step-start"
},
{
"type": "text",
"text": "..."
}
]
}
]
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
Convex Bot
Convex Bot3w ago
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!
erquhart
erquhart3w ago
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.
erquhart
erquhart3w ago
(find "date" on the page)
Daniel Stoll
Daniel StollOP3w ago
Thanks! Is there a way to avoid manually mapping date to string in the generic object before inserting to the convex v.any() field?
erquhart
erquhart3w ago
JSON.parse(JSON.stringify(input)) should work
Daniel Stoll
Daniel StollOP3w ago
Thanks for the help!

Did you find this page helpful?