Skip to content

test(v3): pin union-in-object inference (issue #2654)#6010

Open
pmjnt wants to merge 1 commit into
colinhacks:mainfrom
pmjnt:algora/algora-org-triggerdotdev-colinhacks-zod-2654
Open

test(v3): pin union-in-object inference (issue #2654)#6010
pmjnt wants to merge 1 commit into
colinhacks:mainfrom
pmjnt:algora/algora-org-triggerdotdev-colinhacks-zod-2654

Conversation

@pmjnt
Copy link
Copy Markdown

@pmjnt pmjnt commented May 20, 2026

Summary

Add v3 regression test locking the inferred type for a union nested in z.object so the original #2654 bug can't silently return.

Closes

Fixes Algora bounty: #2654

Disclosure

This PR was AI-assisted (Claude Code) and reviewed by a human before submission.

Fixes Algora bounty: colinhacks#2654

This PR was AI-assisted (Claude Code) and reviewed by a human
before submission.
Copy link
Copy Markdown
Contributor

@pullfrog pullfrog Bot left a comment

Choose a reason for hiding this comment

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

Important

packages/zod/src/v3 is in maintenance mode and only accepts critical security fixes — additional tests, features, and bugfixes are out of scope. Equivalent coverage already exists for v4 at generics.test.ts:51 (nested no undefined), which pins exactly this inference for z.object({ inner: z.string().or(z.array(z.string())) }). The original #2654 bug no longer reproduces on either v3 or v4 — see @colorbank's recent comment reaching the same conclusion in #6003.

TL;DR — Adds a v3 regression test pinning the inferred type of a union nested inside z.object for issue #2654. The behavior is correct on current v3 and v4, but the v3 tree is frozen and a parallel v4 test already covers this case, so there's nothing here to merge.

Key changes

  • Add v3 regression test for union-in-object inference — pins z.infer<typeof z.object({ name: z.string().or(z.array(z.string())) })> to { name: string | string[] } in packages/zod/src/v3/tests/unions.test.ts.

Summary | 1 file | 1 commit | base: mainalgora/algora-org-triggerdotdev-colinhacks-zod-2654


Scope conflict with v3 maintenance mode

Before: No regression test in v3 for the issue #2654 inference shape.
After: A v3 test asserting { name: string | string[] } inference for a union object property.

The packages/zod/src/v3 tree is closed to non-security changes. The equivalent v4 test (nested no undefined) already asserts the exact same inference shape for z.string().or(z.array(z.string())) inside z.object, and additionally checks that { inner: undefined } is rejected at runtime — so the failure mode this PR guards against is already covered on the maintained branch.

packages/zod/src/v3/tests/unions.test.ts

Thanks for the careful writeup, but I don't think there's a path to merge this one.

Pullfrog  | Fix it ➔View workflow run | Using Claude Opus𝕏

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.

1 participant