The expected behavior is that this handler can handle multipart/form-data requests correctly when only userId is included in the request.
Current Behavior
Currently, it outputs an error message like the following:
{
"message": "Cannot read properties of undefined (reading 'length')"
}
Possible Solution
This issue seems to be caused by an incorrect implementation of the template engine, specifically expressTemplateService.ts line 89.
When the file field is optional in @UploadedFile and not included in the actual request, fileArgs becomes undefined. The current implementation does not account for this and tries to call the length property, resulting in the aforementioned error.
To address this issue, the implementation should be modified as follows:
Sorting
I'm submitting a ...
I confirm that I
Expected Behavior
The following code is an example of a post endpoint handler:
The expected behavior is that this handler can handle multipart/form-data requests correctly when only userId is included in the request.
Current Behavior
Currently, it outputs an error message like the following:
Possible Solution
This issue seems to be caused by an incorrect implementation of the template engine, specifically expressTemplateService.ts line 89. When the file field is optional in @UploadedFile and not included in the actual request, fileArgs becomes undefined. The current implementation does not account for this and tries to call the length property, resulting in the aforementioned error. To address this issue, the implementation should be modified as follows:
May I publish pull request for this issue?
Context (Environment)
Version of the library: 6.1.4 Version of NodeJS: 18