Skip to content

Add safety check to handle undefined refSeen.def#5644

Closed
brunolemos wants to merge 1 commit intocolinhacks:mainfrom
brunolemos:fix/undefined-check
Closed

Add safety check to handle undefined refSeen.def#5644
brunolemos wants to merge 1 commit intocolinhacks:mainfrom
brunolemos:fix/undefined-check

Conversation

@brunolemos
Copy link
Copy Markdown

@brunolemos brunolemos commented Jan 18, 2026

Fix the following issue after upgrading from 4.2.1 to 4.3.5:

node_modules/.pnpm/[email protected]/node_modules/zod/v4/core/to-json-schema.cjs:267
                    if (key in refSeen.def && JSON.stringify(schema[key]) === JSON.stringify(refSeen.def[key])) {
                            ^
TypeError: Cannot use 'in' operator to search for 'id' in undefined
    at flattenRef (node_modules/.pnpm/[email protected]/node_modules/zod/v4/core/to-json-schema.cjs:267:29)

As per flagged by copilot bot here: #5578 (comment)

Confirmed this change fixes the issue for me by using pnpm patch.

cc @colinhacks

Fix: TypeError: Cannot use 'in' operator to search for 'id' in undefined
@colinhacks
Copy link
Copy Markdown
Owner

Merged equivalent fix in #5638

Thanks for the PR, apologies for the inconvenience here.

@brunolemos brunolemos closed this Jan 22, 2026
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