fix(media): handle missing path parameter and improve error logging

- Updated `getFile` method to validate `path` query parameter.
- Added improved logging for file retrieval errors.
- Updated test cases to cover scenarios with missing `path`.
This commit is contained in:
Mathis HERRIOT
2026-01-20 21:28:10 +01:00
parent 6a2abf115f
commit d647a585c8
2 changed files with 36 additions and 9 deletions

View File

@@ -49,6 +49,13 @@ describe("MediaController", () => {
expect(stream.pipe).toHaveBeenCalledWith(res);
});
it("should throw NotFoundException if path is missing", async () => {
const res = {} as unknown as Response;
await expect(controller.getFile("", res)).rejects.toThrow(
NotFoundException,
);
});
it("should throw NotFoundException if file is not found", async () => {
mockS3Service.getFileInfo.mockRejectedValue(new Error("Not found"));
const res = {} as unknown as Response;