fix: verbose error handling, batch processing, and multi-file support

- Replace [object Object] errors with readable messages across all 20+ API
  routes by normalizing Zod validation errors to strings (formatZodErrors)
- Add parseApiError() on frontend to defensively handle any details type
- Add global Fastify error handler with full stack traces in logs
- Fix image-to-pdf auth: Object.entries(headers) → headers.forEach()
- Fix passport-photo: safeParse + formatZodErrors, safe error extraction
- Fix OCR silent fallbacks: log exception type/message when falling back,
  include actual engine used in API response and Docker logs
- Fix split tool: process all uploaded images, combine into ZIP with
  subfolders per image
- Fix batch support for blur-faces, strip-metadata, edit-metadata,
  vectorize: add processAllFiles branch for multi-file uploads
- Docker: LOG_LEVEL=debug, PYTHONWARNINGS=default for visibility
- Add Playwright e2e tests verifying all fixes against Docker container
This commit is contained in:
ashim-hq
2026-04-17 14:15:27 +08:00
parent 2e2dbbb8e0
commit 32239600ae
39 changed files with 936 additions and 163 deletions
+3 -8
View File
@@ -1,5 +1,5 @@
import { useCallback, useEffect, useRef, useState } from "react";
import { formatHeaders } from "@/lib/api";
import { formatHeaders, parseApiError } from "@/lib/api";
import { generateId } from "@/lib/utils";
import { useFileStore } from "@/stores/file-store";
import type { PipelineStep } from "@/stores/pipeline-store";
@@ -145,10 +145,7 @@ export function usePipelineProcessor() {
} else {
try {
const body = JSON.parse(xhr.responseText);
const msg = body.details
? `${body.error}: ${body.details}`
: body.error || `Processing failed: ${xhr.status}`;
setError(msg);
setError(parseApiError(body, xhr.status));
} catch {
setError(`Processing failed: ${xhr.status}`);
}
@@ -273,9 +270,7 @@ export function usePipelineProcessor() {
errorMsg += ` (${body.errors.length} files failed)`;
}
} else {
errorMsg = body.details
? `${body.error}: ${body.details}`
: body.error || `Batch processing failed: ${response.status}`;
errorMsg = parseApiError(body, response.status);
}
} catch {
errorMsg = `Batch processing failed: ${response.status}`;
+3 -8
View File
@@ -1,6 +1,6 @@
import { PYTHON_SIDECAR_TOOLS } from "@ashim/shared";
import { useCallback, useEffect, useRef, useState } from "react";
import { formatHeaders } from "@/lib/api";
import { formatHeaders, parseApiError } from "@/lib/api";
import { generateId } from "@/lib/utils";
import { useFileStore } from "@/stores/file-store";
@@ -233,10 +233,7 @@ export function useToolProcessor(toolId: string) {
} else {
try {
const body = JSON.parse(xhr.responseText);
const msg = body.details
? `${body.error}: ${body.details}`
: body.error || `Processing failed: ${xhr.status}`;
setError(msg);
setError(parseApiError(body, xhr.status));
} catch {
setError(`Processing failed: ${xhr.status}`);
}
@@ -357,9 +354,7 @@ export function useToolProcessor(toolId: string) {
let errorMsg: string;
try {
const body = JSON.parse(text);
errorMsg = body.details
? `${body.error}: ${body.details}`
: body.error || `Batch processing failed: ${response.status}`;
errorMsg = parseApiError(body, response.status);
} catch {
errorMsg = `Batch processing failed: ${response.status}`;
}