Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Correctly parse and transform strings to date in /webhook APIs #2285

Merged
merged 1 commit into from
Oct 6, 2023

Conversation

DafyddLlyr
Copy link
Contributor

@DafyddLlyr DafyddLlyr commented Oct 6, 2023

Hit this issue when troubleshooting E2E test (this doesn't fix them yet! 😅)

The change introduced in #2252 validates that incomming requests are valid (e.g. dates), and then hands over the request type to the ValidatedRequestHandler type.

What I missed is that we're never passing along the parsed request to the next middleware layer (but it does pass the type as mentioned above).

This means we end up with strings being passed into functions that expect Date objects. When running E2E tests a number of API requests fail as a result.

@github-actions
Copy link

github-actions bot commented Oct 6, 2023

Removed vultr server and associated DNS entries

@@ -4,7 +4,7 @@ import { ScheduledEventResponse } from "../../../../hasura/metadata";

export const createSessionEventSchema = z.object({
body: z.object({
createdAt: z.string().transform((val) => new Date(val)),
createdAt: z.string().pipe(z.coerce.date()),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is functionally the same, but syntactically a little nicer colinhacks/zod#879 (comment)

@DafyddLlyr DafyddLlyr requested a review from a team October 6, 2023 12:02
@DafyddLlyr DafyddLlyr marked this pull request as ready for review October 6, 2023 12:02
@DafyddLlyr DafyddLlyr merged commit 2ce327e into main Oct 6, 2023
@DafyddLlyr DafyddLlyr deleted the dp/fix-date-handling branch October 6, 2023 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants