fix: surface hidden errors and add batch rejection tests

Fix empty catch blocks in settings dialog (logo upload/delete) and
automate page (pipeline save) that silently swallowed errors. Users
now see error messages when these operations fail.

Add 5 integration tests verifying batch endpoint returns 404 for
custom-route tools (remove-background, upscale, ocr, blur-faces,
erase-object), matching the pipeline rejection tests.
This commit is contained in:
Siddharth Kumar Sah
2026-03-28 14:45:14 +08:00
parent fa01388742
commit 4a504281a3
3 changed files with 31 additions and 3 deletions
@@ -295,7 +295,7 @@ function SystemSection() {
}); });
setSettings((prev) => ({ ...prev, customLogo: "true" })); setSettings((prev) => ({ ...prev, customLogo: "true" }));
} catch { } catch {
/* handle error */ setSaveMsg("Failed to upload logo.");
} }
}; };
@@ -304,7 +304,7 @@ function SystemSection() {
await apiDelete("/v1/settings/logo"); await apiDelete("/v1/settings/logo");
setSettings((prev) => ({ ...prev, customLogo: "false" })); setSettings((prev) => ({ ...prev, customLogo: "false" }));
} catch { } catch {
/* handle error */ setSaveMsg("Failed to delete logo.");
} }
}; };
+4 -1
View File
@@ -66,9 +66,12 @@ export function AutomatePage() {
}); });
if (res.ok) { if (res.ok) {
await loadPipelines(); await loadPipelines();
} else {
const data = await res.json().catch(() => ({}));
setExecutionError(data.error || "Failed to save pipeline");
} }
} catch { } catch {
// Error handling could be added setExecutionError("Connection error while saving pipeline.");
} finally { } finally {
setSaving(false); setSaving(false);
} }
+25
View File
@@ -2668,6 +2668,31 @@ describe("Batch processing", () => {
expect(res.headers["content-type"]).toBe("application/zip"); expect(res.headers["content-type"]).toBe("application/zip");
}); });
}); });
describe("Batch rejects custom-route tools", () => {
const customRouteTools = ["remove-background", "upscale", "ocr", "blur-faces", "erase-object"];
for (const toolId of customRouteTools) {
it(`returns 404 for batch "${toolId}" (custom-route tool)`, async () => {
const { body: payload, contentType } = createMultipartPayload([
{ name: "file", filename: "a.png", contentType: "image/png", content: PNG_200x150 },
{ name: "settings", content: JSON.stringify({}) },
]);
const res = await app.inject({
method: "POST",
url: `/api/v1/tools/${toolId}/batch`,
headers: {
authorization: `Bearer ${adminToken}`,
"content-type": contentType,
},
payload,
});
expect(res.statusCode).toBe(404);
expect(JSON.parse(res.body).error).toContain("not found");
});
}
});
}); });
// ═══════════════════════════════════════════════════════════════════════════ // ═══════════════════════════════════════════════════════════════════════════