Skip to content

fix: populate() crashes with TypeError when passed null - #1049

Merged
motdotla merged 1 commit into
motdotla:masterfrom
webdevelopersrinu:fix-populate-null
Sep 16, 2026
Merged

motdotla merged 1 commit into
motdotla:masterfrom
webdevelopersrinu:fix-populate-null

Conversation

@webdevelopersrinu

Copy link
Copy Markdown
Contributor

populate(process.env, null) crashes with a raw TypeError. It should
throw the OBJECT_REQUIRED error, but typeof null === 'object' passes
the check. populate(null, parsed) crashes too — processEnv was never
checked, even though the error message says to check it.

I fixed the guard to catch null for both arguments. Added two tests.
Tests pass on my machine.

@lbesecker195 lbesecker195 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verified: typeof null === 'object' slips past the existing check, and processEnv was never validated even though the error message names it. The new guard covers both, and the tests exercise both paths. LGTM.

@motdotla
motdotla merged commit fa8788e into motdotla:master Sep 16, 2026
4 checks passed
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.

3 participants