fix: add server-side logging to AI tool routes (#23)

AI routes (remove-background, erase-object, ocr, blur-faces, upscale)
were silently swallowing errors - failures returned HTTP 422 to the
client but never appeared in server logs. This made it impossible for
self-hosters to diagnose issues like 504 timeouts from reverse proxies.

Adds request.log.info() at processing start (tool name, image size, key
settings) and request.log.error() in catch blocks, matching the existing
tool-factory pattern.

Co-authored-by: Siddharth Kumar Sah <siddharth123sk@gmail.com>
This commit is contained in:
stirling-image
2026-04-06 21:00:29 +08:00
committed by GitHub
co-authored by Siddharth Kumar Sah
parent 9e9a22cdd1
commit 75c7f135fe
5 changed files with 35 additions and 0 deletions
@@ -63,6 +63,10 @@ export function registerEraseObject(app: FastifyInstance) {
}
try {
request.log.info(
{ toolId: "erase-object", imageSize: imageBuffer.length, maskSize: maskBuffer.length },
"Starting object erasure",
);
const jobId = randomUUID();
const workspacePath = await createWorkspace(jobId);
@@ -110,6 +114,7 @@ export function registerEraseObject(app: FastifyInstance) {
processedSize: resultBuffer.length,
});
} catch (err) {
request.log.error({ err, toolId: "erase-object" }, "Object erasing failed");
return reply.status(422).send({
error: "Object erasing failed",
details: err instanceof Error ? err.message : "Unknown error",