fix: update corrupted image test expectations from 422 to 400

validateImageBuffer catches corrupt image data before processing
reaches the tool handler, so the correct status code is 400 (bad
request) rather than 422 (processing failure). Also fix SVGZ
watermark validation by returning early for compressed SVG (Sharp
cannot read gzip-compressed SVGZ directly) and passing the actual
watermark filename to validateImageBuffer for correct format
detection.
This commit is contained in:
SnapOtter
2026-05-14 00:09:31 +08:00
parent 2f41629a14
commit cd24bb92b6
4 changed files with 18 additions and 12 deletions
+3 -2
View File
@@ -158,7 +158,7 @@ describe("Error handling", () => {
expect(result.error).toBeDefined();
});
it("returns 422 for corrupted image data", async () => {
it("returns 400 for corrupted image data", async () => {
const badBuffer = Buffer.from("not an image at all");
const { body: payload, contentType } = makeFilePayload(badBuffer, "bad.png", "image/png");
const res = await app.inject({
@@ -170,7 +170,8 @@ describe("Error handling", () => {
authorization: `Bearer ${adminToken}`,
},
});
expect(res.statusCode).toBe(422);
// validateImageBuffer catches corrupt data before processing
expect(res.statusCode).toBe(400);
});
});