8000 v4: The `isPlainObject` util returns false for objects with a nested null prototype · Issue #4573 · colinhacks/zod · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

v4: The isPlainObject util returns false for objects with a nested null prototype #4573

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

Open
antoinechassagne opened this issue May 30, 2025 · 1 comment · May be fixed by #4574
Open

v4: The isPlainObject util returns false for objects with a nested null prototype #4573

antoinechassagne opened this issue May 30, 2025 · 1 comment · May be fixed by #4574

Comments

@antoinechassagne
Copy link

Following up #4270, there is still an unhandled edge case when an object has a nested null prototype.

Example :

isPlainObject(Object.create(null)); // Returns `true`
isPlainObject(Object.create(Object.create(null))); // Returns `false`

This case occurs when you create an object whose prototype is itself null-prototyped. In this case, defining a record as z.record() will fail with error Invalid input: expected record, received object.

@antoinechassagne antoinechassagne linked a pull request May 30, 2025 that will close this issue
@colinhacks
Copy link
Owner
colinhacks commented May 30, 2025

I'm not necessarily opposed to this, but where are you seeing this happen in the wild? I'm not sure this is worth the bundle size & complexity overheads. If this change isn't motivated by something then it just seems unnecessary to me. Whether this even qualifies as "plain" is up for debate. It's actually quite arcane.

@colinhacks colinhacks changed the title v4: The isPlainObject fails on objects with a nested null prototype v4: The isPlainObject util returns false for objects with a nested null prototype May 30, 2025
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 a pull request may close this issue.

2 participants
0