[Snyk] Upgrade zod from 4.3.6 to 4.4.1#203
Closed
patternfly-build wants to merge 1 commit into
Closed
Conversation
Snyk has created this PR to upgrade zod from 4.3.6 to 4.4.1. See this package in npm: zod See this project in Snyk: https://app.snyk.io/org/patternfly-bD6TiY6PxAoojbR6oZkeJN/project/9a961290-4598-4dc0-8ac1-992d3aa7c386?utm_source=github&utm_medium=referral&page=upgrade-pr
Member
|
closing, repeat of #202 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Snyk has created this PR to upgrade zod from 4.3.6 to 4.4.1.
ℹ️ Keep your dependencies up-to-date. This makes it easier to fix existing vulnerabilities and to more quickly identify and fix newly disclosed vulnerabilities when they affect your project.
The recommended version is 15 versions ahead of your current version.
The recommended version was released 21 days ago.
Release notes
Package name: zod
Commits:
4.4.0
This is a minor release with a wide set of correctness and soundness fixes. Some fixes intentionally make Zod stricter, so code that depended on previously accepted invalid or ambiguous inputs may need small updates.
Potentially breaking bug fixes
Tuple defaults now materialize output values correctly
Fixed in #5661. Tuple parsing now more accurately reflects defaults, optional tails, explicit
undefined, and under-filled inputs. The headline behavior is that defaults in tuple positions now properly appear in parsed output.z.string(),
z.string().default("fallback"),
]);
schema.parse(["a"]);
// ["a", "fallback"]
Trailing optional elements that are absent still stay absent; they are not filled with
undefined.z.string(),
z.string().optional(),
]);
schema.parse(["a"]);
// ["a"]
But explicit
undefinedvalues supplied by the caller are preserved.When optional elements appear before later defaults, the parsed tuple is now dense so array operations behave predictably.
z.string(),
z.string().optional(),
z.string().default("fallback"),
]);
schema.parse(["a"]);
// ["a", undefined, "fallback"]
Tuple length errors are also more consistent now. Since
z.function()arguments are tuple-shaped, function input errors may look different.Required object properties with
z.undefined()Fixed in #5661, with follow-up coverage in
57d80a82. A property whose schema isz.undefined()is now treated as required. The key must be present, but its value may beundefined.value: z.undefined(),
});
schema.safeParse({}).success;
// false
schema.safeParse({ value: undefined }).success;
// true
Use
.optional()when the key itself may be absent.value: z.undefined().optional(),
});
schema.safeParse({}).success;
// true
This also affects related
.catch(),.partial(),.default(), and.prefault()combinations that previously relied on missingz.undefined()keys being treated as optional.Safer
.merge()behavior with refinementsFixed in #5856. The
.merge()method now throws when the receiver has refinements, rather than silently producing ambiguous refinement behavior. Refinements from the second schema are preserved.const b = z.object({ b: z.string() });
a.merge(b);
// throws
JSON Schema
$defsentries no longer include redundantidFixed in #5759. JSON Schema conversion through
z.toJSONSchema()now strips redundantidfields from$defsentries. This is required for correctness in older JSON Schema dialects from before$idwas introduced: in those dialects,idchanges the resolution scope, so leaving it inside an extracted definition can make references resolve incorrectly. The removed value was redundant because the schema had already been extracted into$defs, so the definition key itself is the identifier. This may affect consumers that were reading those internalidfields directly.Other JSON Schema fixes in this release:
.describe(): #5797String validators are stricter
Base64 validation now rejects whitespace instead of allowing
atob()-style whitespace stripping. Fixed in #5888.// true
z.base64().safeParse("Zm 9v").success;
// false
Other string validator changes:
z.cuid()has been tightened, and CUID v1 is now deprecated. Fixed in #5880.z.httpUrl()now rejects malformed HTTP(S) URLs with a missing slash after the protocol. The underlyingURLconstructor normalizes inputs likehttps:/example.com, but Zod now rejects them instead of accepting the repaired URL. Fixed in #5672, related to #5284.// true
z.httpUrl().safeParse("https:/example.com").success;
// false
z.httpUrl().safeParse("http:/www.apple.com").success;
// false
Union paths are fixed in formatted errors
Two union-related error fixes landed:
z.treeifyError()andz.formatError(). Fixed in #5708 and60ff3987.ZodErroroutput.Other fixes
Record key transforms now run
Fixed in #5891. Record schemas now run transforms on record keys.
z.string().transform((key) => key.toUpperCase()),
z.number()
);
schema.parse({ foo: 1 });
// { FOO: 1 }
Related record fixes:
invalid_keyissues. Fixed in #5719.z.record(valueType)form works again. Fixed in0e960108.Metadata and input handling in
fromJSONSchema()Schema generation from JSON Schema now applies metadata more consistently across
enum,const,not,anyOf, and multi-type schemas. Fixed in #5758. It also rejects or normalizes more non-JSON-like inputs, including cyclic objects andBigInt. Fixed in87cf0f93.Codecs
Codec changes:
z.discriminatedUnion().encode()now works when the discriminator uses a codec. Fixed in #5769.z.string(),
z.number(),
{
decode: Number,
encode: String,
}
);
const numberToString = z.invertCodec(stringToNumber);
Transform context
Transform callbacks now support
ctx.addIssue(). Fixed in #5699.Conditional
.superRefine()withwhenThe
whenoption was added for.superRefine(). Added in #5741, with related abort behavior fixed in #5681.Defaults for
MapandSetDefaults for
MapandSetare now cloned instead of shared across parses. Fixed in #5855.const a = schema.parse(undefined);
const b = schema.parse(undefined);
a === b;
// false
Empty unions
Empty
z.union([]),z.xor([]), and discriminated unions no longer crash at construction time. They construct and fail at parse time. Fixed in #5869.Floating-point multiples
Number
multipleOf()/step()validation is more accurate for decimal and exponent edge cases. Fixed in #5687 and #5793.Global config and
jitlessConfiguration fixes:
globalThis, improving behavior across mixed CJS/ESM module instances. Fixed in #5889.Prototype pollution hardening
Object catchall paths now skip
__proto__keys. Fixed in #5898.Performance improvements
Reduced memory usage from lazy-bound methods
Fixed in #5897. Classic builder methods are now lazy-bound through a shared internal prototype instead of eagerly attached per schema instance. This significantly reduces per-schema method allocation overhead, especially in codebases that construct many schemas. Detached methods continue to work:
const optional = schema.optional;
optional.call(schema);
// still works
Improved tree-shaking
Implemented in
195e8696and #5689. Top-level factory calls are annotated as pure, and generated stub package manifests now includesideEffects: false. This gives bundlers more room to remove unused Zod code.This is intended as the conclusive fix for a long-standing class of tree-shaking and bundle-size issues, especially in Next.js and Turbopack projects. The most visible symptom was that unused validators and locales could survive bundling even when importing from
zod/minior from a narrow subpath.Related reports include:
zod/minibundle-size reports: #5561, #5665, #4369, #4572{ "sideEffects": false }Locales
Added or updated locale support:
Locale message text changed in some cases, which may affect snapshots.
Closed issues
The following issues were closed by PRs included in this release:
string.abort: truein.refine()checks withwhen.addIssueto transform context.deleteinfinalizeIssue.optionsto invalid discriminator errors.fromJSONSchema().idfrom$defsentries in JSON Schema output.z.custom()docs for v4 compatibility.discriminatedUnion().encode()with codec discriminators.multipleOf()validation.MapandSetdefaults..merge()refinement semantics with.extend().jitlessconfig in the eval probe.z.union([])andz.xor([]).z.record().Commits
44f6a03efix(locales): correct Georgian translation for 'string' to 'ველი' (#5655) by @ tushargr0ver7b43bc64docs(ecosystem): add Hono Takibi (#5651) by @ nakita628119376b9feat: add map support to Uzbek locale (#5599) by @ uchkunr8fbf701etest: add edge case tests for boundary values (#5601) by @ uchkunrf1f93c2bFix order of brand method examples in api.mdx (#5604) by @ onurtemiz10105ee4docs: Fix typos in json-schema documentation (#5608) by @ SaKaNa-Y2d367139feat: add hr translation (#5610) by @ vuki65654902cb7chore: update pullfrog.yml workflow89ba70f2chore: add sideEffects false to stub package.json for tree-shaking (#5689) by @ jesse-holdeneaa3c2c3Update positive checks to use alias.gt(0)in the docs (#5671) by @ Fredkiss365f1f404fix typo (#5676) by @ Nikita0x5b574501fix: respectabort: truein.refine()for checks withwhenfunction (#5681)539de140docs: fix README links for async refinements/transforms (#5682) by @ pavan-sh46cd10e7docs: fix README anchor links for async APIs (#5683) by @ pavan-sh55747b3cRemove deprecated downlevelIteration option (#5684) by @ RyanCavanaugh3a818de1fix(v4): handle multi-digit exponents in floatSafeRemainder (#5687) by @ shakecodeslikecray3cd45ebcfix(v4): add strict validation tohttpUrl()(#5672) by @ LuckySilver00217d98c909add Sanity as silver sponsor and Mintlify as bronze sponsorc7805073move Sanity and Mintlify to top of sponsor listsbee2dc8ddocs: movez.iso.time()from format to pattern section (#5696)2f8414bcfix: add missing addIssue to transform context (#5699) by @ F-A-N-D-Ed3c0ec87docs: add note about removed.errorsalias in v4 changelog (#5705) by @ togami2864fa338a3bfix(v4): JSON schema min/max intersection for draft-04 and openapi-3.0 (#5700) by @ ebroder3473b288chore: bump zshy to ^0.7.1cc8f9b7cdocs: improve README wording and fix typos (#5736) by @ vedanshshettif5336717feat: add json-up to ecosystem (#5740) by @ mrspence60ff3987fix(v4): preserve parent path when treeifying nested union/key/element issues08b14b51perf: avoiddeleteinfinalizeIssueto keep V8 fast mode (#5718)9cf868d2fix(v4): treeify error nested union bug (#5708) by @ dstashevskyi28f39a6dAdd JSONType export (#5709) by @ RobinVdBroeck