Bug
POST /api/uploads returns HTTP 201 with a success envelope even when no file is uploaded. The controller currently maps missing files to a successful no-file status:
return ok(res, {
filename: req.file?.originalname ?? null,
status: req.file ? "uploaded" : "no-file"
}, 201);
Reproduction request:
POST /api/uploads
(no multipart file field)
Observed behavior from current origin/main:
HTTP 201
{ "success": true, "data": { "filename": null, "status": "no-file" } }
Impact
- Failed upload attempts are reported as successful resource creation.
- API clients can treat missing-file requests as completed uploads.
- Upload validation is inconsistent with expected multipart file handling.
Expected behavior
Upload requests without a file should return HTTP 400 using the API failure envelope. Valid uploads should continue to return HTTP 201 with the uploaded filename.
Proposed fix
- Return
fail(res, "File is required", 400) when req.file is missing.
- Preserve the existing successful response for valid uploads.
- Add endpoint regression tests for missing-file and valid-file upload requests.
This issue is limited only to the creator of this issue. This means that only the issue author can attempt to solve this issue. If you would like to work on it, please create another issue with the same contents and refer to issue #743 for more information.
Parent bounty: #743.
Bug
POST /api/uploadsreturns HTTP 201 with a success envelope even when no file is uploaded. The controller currently maps missing files to a successfulno-filestatus:Reproduction request:
Observed behavior from current
origin/main:Impact
Expected behavior
Upload requests without a file should return HTTP 400 using the API failure envelope. Valid uploads should continue to return HTTP 201 with the uploaded filename.
Proposed fix
fail(res, "File is required", 400)whenreq.fileis missing.This issue is limited only to the creator of this issue. This means that only the issue author can attempt to solve this issue. If you would like to work on it, please create another issue with the same contents and refer to issue #743 for more information.
Parent bounty: #743.