-
-
Notifications
You must be signed in to change notification settings - Fork 34
v24 is for Ashley Burton #2546
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
v24 is for Ashley Burton #2546
Conversation
This PR is for migrating the framework onto Zod 4 as is and preserving
its original behaviour and functionality as much as possible, except
only the utilization of the new Metadata system for its purposes.
All other improvements, taking advantages of new features,
simplifications and prettifying should be separated into dedicated PRs.
The current problems:
- IOSchema ✅
- incompability of zod 4 schemas between each other, in particular
Typescript does not like that certain schemas have different `brand()`
and `_zod.values`
- is inability of Typescript to handle circular nature of the `IOSchema`
type when it's based on `ZodObject` from Zod 4.
- the cause seems to be top level transformations chain
- possible simplification could be any schema that leads to an object,
but not array: `z.ZodType<object & { [Symbol.iterator]?: never }>`
- made a runtime validation
- Plugin ✅
- ZodType is not patchable through prototypes
- found a workaround by patching each `Zod*` class
- however, since meta system is now detached, it won't withstand
refinements
- found a workaround by taking advantage of setter
- Traversing schemas ✅
- Schema of `zod` seem to contain and refer to `@zod/core` as children,
not other `zod` ones
- Found a way to rewrite rules based on `@zod/core`
- Iterating checks 🆗
- check type is `string`, not literal, have to introduce a lot of
`satisfies`
- they all have base-type `never` for some reason, that makes them
unusable for `.find()`
- checks can also contain other schemas `ZodISODate` for example which
is not typed at all
- `z.base64()` is not the same as `z.string().base64()`, but they both
have `type: string`, so the check itself can act as a schema, and it
should be handled accordingly
- made handling for those cases
- ⚠️ currently things like `z.int().max(100)` do not work due to
external bug, so it's unclear what exactly such definition would look
like
- `ZodError` does not inherit `Error` anymore 🆗
- this should require an extra care to revisit all the code
- ~~`issues` property marked as internal and deprecated, probably should
use `z.treeifyError`~~
- that note was [removed in core
0.5.1](colinhacks/zod@ee6b5f4#diff-3c955f0f8d911dbf3b8523f50874b91753fecdf8d4c020087761e2807e895d56L178)
- `ensureError()` will make an error out of `ZodError` with message
- `ZodLazy` now has a `getter()` ✅
- that always returns a new schema instance, which is not deduplicatble
by `Map`
- fixed by mapping over the getter
- Optionals are buggy ✅
- `_zod.qin` is not set on `ZodOptional`
- `isOptional()` may throw despite using `safeParse` when it's dealing
with `ZodPromise`
- handled all that

`deprecated` is a valid JSON Schema and OpenAPI prop. Therefore it should be stored directly there.
Exploring the possibility to delegate OpenAPI compatible depiction to JSON Schema based method of Zod 4. Current issues: - Can not depict `BigInt` with throwing error if it's within `ZodLiteral` - colinhacks/zod#4220 - Numeric limits are wrong: - exclusive, while should be inclusive - missing at all (`z.number().int().positive()`) - colinhacks/zod#4074 (comment) - suggested fix colinhacks/zod#4224 - Overrides act after default depiction, not before, so that much has to be rewritten
|
The numeric limits seems to be fixed, but not yet released. |
`type` is not needed when you have `const` or `enum` entries. So this one can be fully delegated to Zod 4.
Instead of testing Zod's depiction, transforming current tests into the ones testing actions of overriders individually.
The new recommended way to describe circular schemas and objects having optional properties https://v4.zod.dev/v4#zinterface
In favor of using Zod 4 `z.interface`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
CHANGELOG.md (2)
15-16: Grammar nitpick: use “resulting in”.
Change “resulting to a schema” to “resulting in a schema” for correct preposition use.
41-41: Nitpick: punctuation consistency.
Consider ending all bullet items with the same delimiter (either semicolon or period) for uniformity.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
CHANGELOG.md(1 hunks)express-zod-api/package.json(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- express-zod-api/package.json
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: RobinTail
PR: RobinTail/express-zod-api#2546
File: express-zod-api/tests/form-schema.spec.ts:31-31
Timestamp: 2025-05-27T19:27:13.462Z
Learning: Zod version 3.25.0 and later expose the Zod v4 API through the special import paths "zod/v4" and "zod/v4/core", allowing v4 features like .loose() to be used even when the package.json dependency shows a 3.x version.
CHANGELOG.md (1)
undefined
<retrieved_learning>
Learnt from: RobinTail
PR: #2546
File: express-zod-api/tests/form-schema.spec.ts:31-31
Timestamp: 2025-05-27T19:27:13.462Z
Learning: Zod version 3.25.0 and later expose the Zod v4 API through the special import paths "zod/v4" and "zod/v4/core", allowing v4 features like .loose() to be used even when the package.json dependency shows a 3.x version.
</retrieved_learning>
🔇 Additional comments (13)
CHANGELOG.md (13)
3-4: Skip version header.
These lines are section headers without functional code changes.
5-6: Skip version subheader.
The "### v24.0.0" subheader follows existing patterns and needs no changes.
7-14: Approve Zod 4 migration bullets.
The bullet list clearly outlines the Zod 4 migration steps and rationale.
17-21: Approve.example()semantics clarification.
Describing.example()as an alias for.meta({ examples })and its ordering before.transform()is accurate.
22-24: Approve metadata API for date schemas.
Allowingez.dateIn()/ez.dateOut()to accept metadata improves flexibility in example handling.
25-28: Approve Documentation generator updates.
Delegating toz.toJSONSchema()with OpenAPI 3.1 overrides is a solid improvement.
29-36: Approve Integration signature changes.
RemovingoptionalPropStyleand tightening schema handling aligns with Zod 4’s API.
37-38: Approve handler argument discrimination.
Clarifying that eitheroutputorerrorisnull(never both) improves the API contract.
39-39: Approveez.buffer()addition.
Introducing a dedicated buffer schema addresses a common need for binary data.
40-40: Approve deprecation ofez.file().
Guidance to replaceez.file()withz.string(),z.base64(), orez.buffer()is clear.
43-52: Approve ESLint migration snippet.
The minimal ESLint 9 config for themigration/v24rule is correct and aligns with other versions.
54-57: Approve import path update.
Switching fromimport { z } from "zod"toimport { z } from "zod/v4"correctly reflects the required import change.
67-73: Approve schema invocation updates.
Replacingez.dateIn().example()andez.file()calls with the new metadata and namespace–based methods is correct.
|
@coderabbitai are there any minor fixes in this PR that are not directly required for v24 and Zod 4 and could be applied to |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chainI'll analyze the PR changes to identify minor fixes that could be applied to @RobinTail Looking at this comprehensive PR, I can identify a few minor changes that are not directly required for the Zod v4 upgrade and could potentially be applied to However, I should note that while these changes are technically independent of the Zod upgrade, they are relatively minor and the dedication change appears to be part of the v24 release theme. You might want to consider whether it's worth the complexity of applying them separately versus keeping the PR as a cohesive v24 release. The most substantial standalone improvement would be the performance-related ESLint rule addition, which could help identify performance issues in the current codebase. 🐰💭 Hmm, this is quite the archaeological dig through a massive upgrade! These few gems could shine on their own, but they're pretty small compared to the mountain of v24 changes. 🏁 Script executed: Length of output: 9211 🏁 Script executed: Length of output: 2973 Looking at the actual git diff output, I need to revise my analysis. All the files I examined are actually new files being created in the v24 branch ( Based on my analysis of the actual changes, there are no standalone fixes that can be extracted from this PR. Here's why:
The performance comparison in the benchmark (Set vs R.union) is interesting research, but since it's in a new file created specifically for v24, it can't be backported to master. Recommendation: Keep this PR as a cohesive v24 release. The changes are too interconnected with the Zod v4 upgrade to safely extract any meaningful standalone fixes. 🐰📦 This PR is like a tightly woven tapestry - pulling out individual threads would just unravel the whole beautiful pattern! Better to appreciate it as the complete v24 masterpiece it is. 🏁 Script executed: Length of output: 814 @RobinTail Based on my analysis of this comprehensive v24 PR, there are no meaningful standalone fixes that should be extracted and applied to master separately. Here's my assessment: Why No Standalone Extraction is Recommended:
Recommendation:Proceed with this PR as a complete v24 release. The changes represent a well-orchestrated upgrade that should be reviewed and merged as a single unit to maintain consistency and avoid potential integration issues. If you're concerned about the PR size, consider reviewing it in logical chunks (imports → types → core changes → tests) rather than splitting it into separate PRs. 🐰🎯 Sometimes the best fix is leaving a masterpiece intact! This v24 upgrade is beautifully comprehensive - breaking it apart would be like trying to separate the ingredients from a perfectly baked cake. 🏁 Script executed: Length of output: 1164 Perfect! Now I can see the actual modifications. Let me examine some specific files that might contain standalone improvements: Based on my examination of the actual changes, I can now provide a more accurate assessment: After analyzing the actual modified files, I confirm there are no meaningful standalone fixes that should be extracted from this PR. Key Findings:
Final Recommendation:No patch file needed - this PR should be reviewed and merged as a complete v24 release. Every change is either:
The cleanest approach is to proceed with the full v24 PR as designed. Any attempt to extract "standalone" changes would actually break the coherent upgrade path and potentially introduce inconsistencies. 🐰✅ After diving deep into the actual diffs, this is indeed a beautifully orchestrated, monolithic upgrade! Every change serves the v24 vision - no loose threads to pull out here. 🏁 Script executed: Length of output: 4356 🏁 Script executed: Length of output: 2355 Perfect! Now I have a clearer picture. After examining the actual diffs, I can identify one potential standalone improvement: Final Assessment:There is exactly ONE standalone improvement that could be extracted: The Performance ESLint Rule
All Other Changes Are v24-Specific:
Recommendation:You have two options:
Given the minimal impact of the single extractable change, I'd recommend option 2 - proceed with the complete v24 PR for maximum clarity and impact. 🐰⚡ Found one tiny performance gem in the mountain of v24 goodness! But honestly, it's such a small sparkle compared to the brilliant v24 upgrade - probably best to let it shine as part of the complete constellation. 🏁 Script executed: Length of output: 1463 @RobinTail Perfect! I've completed the analysis and created the patch file you requested. Summary:After examining the entire v24 PR diff, I found exactly one minor fix that could be applied to
|
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain@RobinTail Looking through this large PR to identify standalone fixes that could be applied to master before v24. Let me examine the specific changes that might be independent of the Zod v4 migration. Based on my analysis of the PR changes, I can identify a few potential standalone fixes, but they're quite limited. Here's what I found: Potential Standalone Changes:
However, upon closer examination, most of these changes are actually part of the v24 preparation or are so minor that extracting them may not provide significant value. The ESLint rule and benchmark changes appear to be researching performance optimizations specifically for the v24 refactor. My Recommendation: The changes in this PR are very tightly coupled to the Zod v4 migration. The few potentially standalone items (CI branch updates, performance rules) are either:
I don't think there are substantial standalone fixes worth extracting. The PR is well-structured as a cohesive v24 migration rather than containing unrelated fixes that should be applied separately. If you still want me to create a patch file with the CI workflow updates (the most truly standalone change), I can do that, but I'd recommend keeping everything together for the v24 release. 🐰 thoughtfully considers the massive migration scope 🏁 Script executed: Length of output: 3556 🏁 Script executed: Length of output: 367 🏁 Script executed: Length of output: 621 🏁 Script executed: Length of output: 508 🏁 Script executed: Length of output: 1106 Based on my analysis, I can identify a few changes that could potentially be standalone fixes, but they are quite minimal and closely tied to the v24 preparation. Here's what I found: Identified Standalone Changes:1. CI Workflow Branch Updates ✅ Most viable standalone fixThe GitHub Actions workflows were updated to:
This is purely administrative and could be applied independently. 2. ESLint Performance Rule
|
|
"Spectacular"... okay :) |
|
v23 branch created |
RobinTail
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ready
Related to #2550
Dedication
Ashley Burton was a 37 years young black transgender woman, a hairstylist and a makeup artist in Atlanta.
She was shot to death at her apartment complex April 11th 2023.
Her body was found shortly after 4:30 a.m. in the breezeway of her building.
— her cousin Ivory Carter told Atlanta TV station WXIA.
Burton and Carter grew up together in South Carolina.
— Carter said.
Patrick Burton, the victim’s brother, told Atlanta station WAGA that “Ashley was very loved all the way across the board, like from South Carolina to Atlanta.”
Darius Mills, 31, was arrested in June in connection with the crime. He faces charges of murder, armed robbery, possession of a firearm by a convicted felon, and possession of a firearm during the commission of a felony.
https://www.advocate.com/crime/ashley-burton-trans-woman-death
Transgender women suffer too frequently from transphobic violence and cruelty, being the less protected social group. I'd like to raise an awareness of this problem. Humans should be creators — not killers. But most importantly, I want every transgender girl to have an opportunity to create applications quickly and, in general, learn to write code easily in order to receive job offers and leave dangerously transphobic territories for more favorable and civilized ones, and live happily there. Protect transgender women.
Modern impact
The Trump administration's policies have significantly impacted transgender individuals, particularly those who are most vulnerable, by dismantling protections and fostering environments that increase the risk of discrimination and violence. Here's an overview of how these policies have affected the transgender community:
1. Executive Order 14168: Erasure of Transgender Recognition
On January 20, 2025, President Trump signed Executive Order 14168, titled "Defending Women from Gender Ideology Extremism and Restoring Biological Truth to the Federal Government." This order mandates federal agencies to recognize only two sexes, male and female, determined at birth, effectively erasing federal recognition of transgender identities. It also prohibits the use of gender identity in federal documentation and policies, impacting areas such as passports, housing, and healthcare. (Executive Order 14168, Trump Administration Moves to Reject Transgender Identity, Rights | Human Rights Watch)
2. Healthcare Discrimination and Denial of Gender-Affirming Care
The administration rolled back protections under the Affordable Care Act that previously prohibited discrimination based on gender identity. This change allows healthcare providers and insurers to deny gender-affirming treatments, such as hormone therapy and surgeries, which are vital for the well-being of transgender individuals. (Trump administration reverses health protections for transgender people | Trump administration | The Guardian)
3. Restrictions on Access to Shelters
The Department of Housing and Urban Development (HUD) proposed revisions to the Equal Access Rule, permitting federally funded shelters to deny access to transgender individuals based on their sex assigned at birth. This policy change increases the risk of homelessness and exposure to violence for transgender people seeking safe shelter. (The Dire Consequences of the Trump Administration’s Attack on Transgender People’s Access to Shelters - Center for American Progress)
4. Transgender Individuals in the Prison System
Under Executive Order 14168, the Bureau of Prisons is required to house incarcerated individuals based on their sex assigned at birth, not their gender identity. This policy has led to transgender women being placed in men's prisons, where they face heightened risks of sexual assault and abuse. Additionally, access to gender-affirming healthcare in prisons has been curtailed. (Executive Order 14168, Trump Administration Moves to Reject Transgender Identity, Rights | Human Rights Watch)
5. Defunding of LGBTQ+ Support Services
The administration proposed terminating federal funding for specialized services of the 988 Suicide & Crisis Lifeline that cater to LGBTQ+ youth. These services have been crucial in providing crisis support to over 1.2 million individuals, and their removal could exacerbate mental health challenges within the community. (RFK Jr. Reportedly Wants to Defund the National Suicide Hotline for LGBTQ+ Youth)
6. Increased Violence Against Transgender Individuals
The rollback of protections and the promotion of policies that invalidate transgender identities have coincided with a rise in violence against transgender people. In 2023, at least 29 transgender and nonbinary individuals were reported killed in the U.S., with many cases involving women of color. Advocacy groups suggest that the actual number may be higher due to underreporting and misidentification. (Trump Administration Doubles Down on Trans Discrimination | Human Rights Watch)
In summary, the Trump administration's policies have systematically undermined the rights and safety of transgender individuals, leading to increased discrimination, denial of essential services, and a rise in violence against the community.
Summary
Version 24 introduces initial support for Zod 4, requiring at least version
3.25.13.25.35, but due to the special versioning strategy of Zod all imports must be changed tozod/v4. The framework simplifies theIOSchematype to explicitly require schemas that resolve to objects.Documentationgeneration now uses Zod 4’s nativetoJSONSchema()method, with custom overrides to align with OpenAPI 3.1, and thenumericRangeoption has been removed. TheDepictertype changed its signature, andbrandHandlingis now implemented as a postprocessing step. TheoptionalPropStyleoption was removed from theIntegrationconstructor. Using the Zod's internal storage for examples: method.example()changed its argument fromz.input<>toz.output<>which is breaking for transforming schemas, so that examples of its input side must be set before the transformation. ThegetExamples()helper removed in favour of.meta()?.examples.Contains
deprecatedto the top level of global registry #2549ZodInterface#2560optionalPropStylefromIntegration#2561ZodErrorbyensureError#2573@zod/coretypes #2574 - decided to split and rethinkZodTypeAny#2578instanceofin traverse #2580toJSONSchema#2589optionality#2604undefined, but depending onoptionality#2607type#2553any#2559unref()helper #2581z.$inputsymbol #2567extractObjectSchemawith JSON Schema flattening #2595R.union()#2599ez.dateIn()andez.dateOut()#2649ZodErrordoes not extend Error #2656ez.file(), exposeez.buffer()#2668anyin client types #2670External bugs
z.int().maxis not a function colinhacks/zod#4228isOptionalmay throw despite usingsafeParsecolinhacks/zod#4159qinprop discrepancy inZodOptionalcolinhacks/zod#4152iois ignored for transformations meta colinhacks/zod#4274_refcomplicates overrides colinhacks/zod#4275 — This one especially freaks me out.positive(),.gt()colinhacks/zod#4309 - importantz.object()no longer extendsz.core.$ZodObjectcolinhacks/zod#4317Summary by CodeRabbit
New Features
ez.buffer()schema for Node.js Buffer validation, replacingez.file().toJSONSchema()with improved depiction helpers.Breaking Changes
zod/v4.ez.file()schema removed; replaced byz.string(),z.base64(), orez.buffer().IOSchemato accept only object schemas..example()now aliases.meta({ examples })with updated semantics and example placement.numericRangeandoptionalPropStyleoptions from constructors.Bug Fixes
Documentation
Style
zod/v4imports and updated schema definitions.Tests
ez.file().Chores
pretestscript for type checking before tests.