Repository navigation
fix(common): reject null file input in ParseFilePipe - #17598
Merged
kamilmysliwiec merged 1 commit intoAug 28, 2026
Merged
Conversation
ParseFilePipe.thereAreNoFilesIn() only checked for `undefined` via isUndefined(), so a `null` value was treated as "a file is present". This let `null` bypass the fileIsRequired check, and skip validators that already treat a falsy file as trivially valid (e.g. MaxFileSizeValidator returns true when `!file`), silently letting a required file argument resolve to `null` instead of throwing. Switch to isNil() so `null` and `undefined` are handled the same way.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
PR Type
What is the current behavior?
ParseFilePipe.thereAreNoFilesIn()only checks forundefinedviaisUndefined(). When the value isnullinstead, it's treated as if a file were present:fileIsRequiredcheck is skipped, even thoughfileIsRequireddefaults totrue.MaxFileSizeValidator.isValid()returnstruewhen!file) also silently passes.As a result,
new ParseFilePipe().transform(null)resolves tonullinstead of throwing, and the failure only surfaces later as aTypeErrorwhen the handler dereferences the file.What is the new behavior?
thereAreNoFilesIn()now usesisNil()instead ofisUndefined(), sonullandundefinedare handled identically — both correctly trigger the "File is required" exception (or the registered validators, iffileIsRequiredisfalse).Two regression tests were added:
nullwithfileIsRequired: truenow throwsBadRequestException.nullwith a validator that mimics the built-in "skip validation when no file" behavior (likeMaxFileSizeValidator) now still throws, instead of silently passing.Does this PR introduce a breaking change?
nullwas never valid/expected input for a required file parameter; this only makes the pipe reject it explicitly instead of silently letting it through.