Repository navigation
fix: treat an empty @UploadedFiles array as missing when the parameter is required - #1557
Open
suresh-saini wants to merge 1 commit into
Open
suresh-saini wants to merge 1 commit into
suresh-saini wants to merge 1 commit into
Conversation
…r is required A multipart request that carries other fields but no file reaches the handler as an empty array (multer sets req.files = []), not as undefined, so the required check let it through and the action ran with no files. An absent @uploadedfile was already rejected because req.file stays undefined.
suresh-saini
force-pushed
the
fix/required-uploaded-files-empty-array
branch
from
October 7, 2026 13:26
b43f0ad to
ad22256
Compare
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.
Description
@UploadedFiles('photos', { required: true })does not reject a multipart request that carries other fields but no file. multer setsreq.files = []for a parsed multipart body, and the generic required check inActionParameterHandler.handleValueonly treatsnull,undefinedand''as empty, so the empty array passes and the action runs with no files.@UploadedFileis not affected becausereq.filestaysundefined.This adds an explicit branch for
filesparameters that also treats an empty array as missing, raising the sameParamRequiredErroras every other required parameter.Checklist
@UploadedFiles when required is used a multipart request with other fields but no file is a bad request), which fails ondevelop(500 → expected 400) and passes with the fixnpm run prettier:check,npm run lint:check(the one pre-existing lint error on this file is untouched),npm testforaction-params.spec.tsObserved on routing-controllers 0.11.3 with Express.