-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
help wantedIssues looking for someone to run with them!Issues looking for someone to run with them!improve or update documentationEnhance / update existing documentation (e.g. add example, improve description, update for changes)Enhance / update existing documentation (e.g. add example, improve description, update for changes)
Description
Astro Info
Astro v5.7.10
Node v22.15.0
System Linux (x64)
Package Manager bun
Output static
Adapter none
Integrations none
If this issue only occurs in one browser, which browser is a problem?
Chrome
Describe the Bug
So, when you pass a date object inside an actions, it is interpolated as a string and then astro actions gives an Error that says date expected, received string
for example:
src/actions/index.ts
import { defineAction } from "astro:actions";
import { z } from "astro:schema";
export const server = {
take_date: defineAction({
input: z.object({
date: z.date(),
}),
handler: async ({ date }) => {
console.log("Date : ", date);
},
}),
};
src/pages/index.astro
<html lang="en">
<head>
<title>Astro</title>
</head>
<body>
<button>Send Date Object to Actions</button>
</body>
</html>
<script>
import { actions } from 'astro:actions';
const button = document.querySelector('button');
button?.addEventListener('click', async () => {
const { data, error } = await actions.take_date({ date: new Date() });
console.log(error)
})
</script>
error
ActionInputError: Failed to validate: [
{
"code": "invalid_type",
"expected": "date",
"received": "string",
"path": [
"date"
],
"message": "Expected date, received string"
}
]
What's the expected result?
the date should be interprolated as a date
Link to Minimal Reproducible Example
https://stackblitz.com/edit/withastro-astro-vn82acp4
Stackblitz wont show the error client side, for some reason it spits out a HTML Document when it is suppossed to log the error message from astro actions. however, with the same code, you can see the error on your local machine
Participation
- I am willing to submit a pull request for this issue.
Metadata
Metadata
Assignees
Labels
help wantedIssues looking for someone to run with them!Issues looking for someone to run with them!improve or update documentationEnhance / update existing documentation (e.g. add example, improve description, update for changes)Enhance / update existing documentation (e.g. add example, improve description, update for changes)