Skip to content

fix(core): throw UndefinedDependencyException for null/undefined in factory provider inject array - #17612

Merged
kamilmysliwiec merged 2 commits into
nestjs:masterfrom
jyx-07:fix/factory-inject-null-check
Aug 29, 2026
Merged

kamilmysliwiec merged 2 commits into
nestjs:masterfrom
jyx-07:fix/factory-inject-null-check

Conversation

@jyx-07

@jyx-07 jyx-07 commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Related to #17607 (identified by @micalevisk)

Factory providers with inject: [null] or inject: [undefined]
currently throw a raw TypeError deep in
isOptionalFactoryDependency() / mapFactoryProviderInjectArray()
because neither function guards against null/undefined before
dereferencing .token or using the in operator.

Fix: add isNil() guards at both call sites so null/undefined
entries in the inject array produce a proper
UndefinedDependencyException with a clear message instead of
a raw TypeError.

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