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
+21
View File
@@ -1,5 +1,26 @@
const API_BASE = "/api";
export function parseApiError(body: Record<string, unknown>, fallbackStatus: number): string {
const error = typeof body.error === "string" ? body.error : "";
const details = body.details;
if (!details) {
return error || (body.message as string) || `Processing failed: ${fallbackStatus}`;
}
let detailsStr: string;
if (typeof details === "string") {
detailsStr = details;
} else if (Array.isArray(details)) {
detailsStr = details
.map((d) =>
typeof d === "string" ? d : (d as Record<string, unknown>)?.message || JSON.stringify(d),
)
.join("; ");
} else {
detailsStr = JSON.stringify(details);
}
return error ? `${error}: ${detailsStr}` : detailsStr;
}
// ── Auth Headers ───────────────────────────────────────────────
function getToken(): string {