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
+10
View File
@@ -55,6 +55,15 @@ export function registerBlurFaces(app: FastifyInstance) {
try {
const settings = settingsRaw ? JSON.parse(settingsRaw) : {};
request.log.info(
{
toolId: "blur-faces",
imageSize: fileBuffer.length,
blurRadius: settings.blurRadius,
sensitivity: settings.sensitivity,
},
"Starting face blur",
);
// Auto-orient to fix EXIF rotation before face detection
fileBuffer = await autoOrient(fileBuffer);
@@ -111,6 +120,7 @@ export function registerBlurFaces(app: FastifyInstance) {
faces: result.faces,
});
} catch (err) {
request.log.error({ err, toolId: "blur-faces" }, "Face blur failed");
return reply.status(422).send({
error: "Face blur failed",
details: err instanceof Error ? err.message : "Unknown error",