Skip to content

feat(parser): support Standard Schema and upgrade to Zod v4 #4164

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

Merged
merged 19 commits into from
Jul 13, 2025

Conversation

dreamorosi
Copy link
Contributor

@dreamorosi dreamorosi commented Jul 13, 2025

Summary

Changes

Please provide a summary of what's being changed

This PR updates the codebase to Zod v4 and adds support for it in Parser, as well as making the parser Middy.js middleware and class method decorator Standard Schema compatible, meaning it can now accept and parse events using Valibot and other parsing libraries.

The PR diff is large, unfortunately I wasn't able to make updates in an orderly fashion because the migration from Zod v3 to v4 has been quite painful. While the upgrade guide is extensive, it focuses primarily on application developers (aka end users). Likewise, the page dedicated to library authors mainly explains how to accept schemas, but falls short of showing complex types or interaction between customer-provided schemas and build-in schemas.

The bulk of the changes in this PR focuses on the built-in envelopes and their unit tests. Envelopes are the area in the utility that is more opinionated and have Zod schemas mixed with custom logic and custom errors. Because of this, the changes required are fairly spread out, causing a large diff.

Aside from this, the rest of the work has gone in expanding types to support Standard Schema and documentation, both in the docs page as well as within the code.

Finally, while working on this I realized that while we had type-checked tests in the Parser utility, these were not actually type-checking but only showing errors in the IDE. I updated the package vitest config to make sure they run correctly.

Thank you in advance for your help reviewing.

Please add the issue number below, if no issue is present the PR might get blocked and not be reviewed

Issue number: closes #3951, closes #2431


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@dreamorosi dreamorosi requested a review from svozza July 13, 2025 02:05
@dreamorosi dreamorosi self-assigned this Jul 13, 2025
@boring-cyborg boring-cyborg bot added dependencies Changes that touch dependencies, e.g. Dependabot, etc. documentation Improvements or additions to documentation internal PRs that introduce changes in governance, tech debt and chores (linting setup, baseline, etc.) parser This item relates to the Parser Utility labels Jul 13, 2025
@pull-request-size pull-request-size bot added the size/XXL PRs with 1K+ LOC, largely documentation related label Jul 13, 2025
Copy link
Contributor

@svozza svozza left a comment

Choose a reason for hiding this comment

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

Great work. I really like how much cleaner the generic type function signatures are now.

dreamorosi and others added 8 commits July 13, 2025 11:26
Co-authored-by: Stefano Vozza <svozza@amazon.com>
Co-authored-by: Stefano Vozza <svozza@amazon.com>
Co-authored-by: Stefano Vozza <svozza@amazon.com>
Co-authored-by: Stefano Vozza <svozza@amazon.com>
Co-authored-by: Stefano Vozza <svozza@amazon.com>
Co-authored-by: Stefano Vozza <svozza@amazon.com>
Co-authored-by: Stefano Vozza <svozza@amazon.com>
Co-authored-by: Stefano Vozza <svozza@amazon.com>
Copy link

Please retry analysis of this Pull-Request directly on SonarQube Cloud

Copy link

@dreamorosi dreamorosi requested a review from svozza July 13, 2025 10:35
@dreamorosi dreamorosi merged commit 67549f6 into main Jul 13, 2025
46 checks passed
@dreamorosi dreamorosi deleted the feat/parser_standard_schema branch July 13, 2025 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Changes that touch dependencies, e.g. Dependabot, etc. documentation Improvements or additions to documentation internal PRs that introduce changes in governance, tech debt and chores (linting setup, baseline, etc.) parser This item relates to the Parser Utility size/XXL PRs with 1K+ LOC, largely documentation related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Support Zod 4.x Feature request: Plans for alternative parser implementations
2 participants