mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
fix: harden install queue/dispatcher lifecycle and repair review-sweep regressions (#395)
Fixes 15 defects found by a max-effort multi-agent review of the last 6 merged PRs (#388, #390, #391, #392, #393, #394), all adversarially verified before fixing. Install queue + dispatcher (the serious cluster): - features.ts: finalize the installer child exactly once. A failed spawn fires both "error" and "close", and the second event released the file lock and active slot that pump() had just handed to the next queued bundle, letting two pip processes write the same venv concurrently. Outcome recording now happens before pump() so the next bundle's first progress frame cannot race the previous install's bookkeeping. - feature-status.ts: keep failed-install errors in a per-bundle map instead of the single progress slot. With the queue auto-starting the next install, the slot was overwritten within seconds and a failed install vanished without ever surfacing to GET /features. - bridge.ts: scope child lifecycle per process (stopped-children set + request generation tags) instead of an instance-wide shuttingDown flag that the next spawn reset. A stale SIGTERMed child's late close event could record a phantom crash (5 of which permanently disable the dispatcher), null out the freshly spawned child, and reject the new child's pending requests. The request-timeout kill path still counts as a real crash. - install_feature.py: the pre-write disk re-check measured ai_dir's filesystem even when budgeting the cross-filesystem copy that lands on the venv's disk; now each budget is checked against the filesystem the bytes actually land on, so ENOSPC cannot strike mid-write and leave site-packages half overwritten. Behavior regressions: - embed-subtitles: preserve pre-existing subtitle tracks (0:s?) and MKV attachments (0:t?) that the -map 0:v:0/0:a? rewrite silently dropped; data streams stay unmapped on purpose (the actual MPEG remux fix). The new subtitle maps first so the language tag hits the right stream. - usage-survey-overlay: fail closed when the settings fetch fails; the fail-open path rendered the blocking survey against an unhealthy API and soft-locked admins, the lock-out class #392 fixed. - features-store: queued bundles poll instead of each holding an SSE connection (Install All could pin 7 EventSources and exhaust the browser's 6-per-origin HTTP/1.1 limit, hanging the whole app); listenToProgress closes any prior stream and stops any poll before subscribing; installAll skips bundles already installing or queued. Contracts, tests, i18n: - openapi.yaml: add "queued" to the features status enum and document downloadBytes/installedBytes (Schemathesis conformance). - feature-lifecycle e2e: queue transcription (~0.5 GB) instead of ocr (~6 GB) and give the test a budget that covers both install drains (the stacked waits exceeded the old 900s timeout). - docker-compose.qa.yml: parameterize the host port (QA_APP_PORT) so QA_PROJECT_NAME concurrent stacks can actually bind. - compare + watermark-image: restore per-input error attribution ("Invalid first/second image", "Invalid watermark image") lost in the shared-handler migration. - ai-features-section: the "{size} on disk" suffix now goes through i18n; key added to all 21 locales. - watermark-image + content-aware-resize: migrate to the shared inputHandlerFor("image") chain like compare/vectorize/compose, fixing drift in the inline copies (no SVG sanitize, no RAW extension hint, no AVIF probe). Verified: typecheck across 9 workspaces, Biome clean on all changed files, 584 targeted unit tests and 249 integration tests green (including real-ffmpeg embed-subtitles runs). One unit test updated to the new poll-while-queued contract with a single-EventSource assertion. Claude-Session: https://claude.ai/code/session_017mR1HiHaf3a1BmUtrHX4j3
This commit is contained in:
@@ -257,9 +257,18 @@ export function getInstallingBundle(): {
|
||||
let currentProgress: {
|
||||
bundleId: string;
|
||||
progress: { percent: number; stage: string } | null;
|
||||
error: string | null;
|
||||
} | null = null;
|
||||
|
||||
/**
|
||||
* Failed-install errors keyed by bundle. Errors live outside the single
|
||||
* progress slot because the queue pump starts the next install immediately
|
||||
* after a failure: if the error sat in the slot, the next bundle's first
|
||||
* progress frame would overwrite it and the failure would never surface to
|
||||
* GET /features. An entry clears when a new install of the same bundle
|
||||
* starts (its first setInstallProgress call with a null error).
|
||||
*/
|
||||
const installErrors = new Map<string, string>();
|
||||
|
||||
export function setInstallProgress(
|
||||
bundleId: string | null,
|
||||
progress: { percent: number; stage: string } | null,
|
||||
@@ -267,9 +276,20 @@ export function setInstallProgress(
|
||||
): void {
|
||||
if (!bundleId) {
|
||||
currentProgress = null;
|
||||
installErrors.clear();
|
||||
return;
|
||||
}
|
||||
currentProgress = { bundleId, progress, error };
|
||||
if (error !== null) {
|
||||
installErrors.set(bundleId, error);
|
||||
if (currentProgress?.bundleId === bundleId) currentProgress = null;
|
||||
return;
|
||||
}
|
||||
installErrors.delete(bundleId);
|
||||
if (progress === null) {
|
||||
if (currentProgress?.bundleId === bundleId) currentProgress = null;
|
||||
return;
|
||||
}
|
||||
currentProgress = { bundleId, progress };
|
||||
}
|
||||
|
||||
// ── Manifest reading ────────────────────────────────────────────────────
|
||||
@@ -519,14 +539,15 @@ export function getFeatureStates(): FeatureBundleState[] {
|
||||
let error: string | null = null;
|
||||
let progress: { percent: number; stage: string } | null = null;
|
||||
|
||||
const installError = installErrors.get(bundle.id) ?? null;
|
||||
if (lock && lock.bundleId === bundle.id) {
|
||||
status = "installing";
|
||||
if (currentProgress && currentProgress.bundleId === bundle.id) {
|
||||
progress = currentProgress.progress;
|
||||
if (currentProgress.error) {
|
||||
status = "error";
|
||||
error = currentProgress.error;
|
||||
}
|
||||
}
|
||||
if (installError) {
|
||||
status = "error";
|
||||
error = installError;
|
||||
}
|
||||
} else if (installedBundle) {
|
||||
// Verify model files exist and are properly sized
|
||||
@@ -540,9 +561,9 @@ export function getFeatureStates(): FeatureBundleState[] {
|
||||
} else if (queuedIds.has(bundle.id)) {
|
||||
// Waiting behind the active install in the server-side queue.
|
||||
status = "queued";
|
||||
} else if (currentProgress?.bundleId === bundle.id && currentProgress.error) {
|
||||
} else if (installError) {
|
||||
status = "error";
|
||||
error = currentProgress.error;
|
||||
error = installError;
|
||||
}
|
||||
|
||||
const archive = manifest?.bundles[bundle.id]?.archives?.[arch];
|
||||
|
||||
@@ -6450,11 +6450,22 @@ paths:
|
||||
description: Human-readable description of the feature bundle
|
||||
status:
|
||||
type: string
|
||||
enum: [installed, not_installed, installing, error]
|
||||
enum: [installed, not_installed, installing, queued, error]
|
||||
installedVersion:
|
||||
type: [string, "null"]
|
||||
estimatedSize:
|
||||
type: string
|
||||
downloadBytes:
|
||||
type: [integer, "null"]
|
||||
description: >-
|
||||
Compressed archive size for this host's
|
||||
architecture, when the manifest records it. Null in
|
||||
native (non-Docker) mode or when unmeasured.
|
||||
installedBytes:
|
||||
type: [integer, "null"]
|
||||
description: >-
|
||||
Extracted on-disk size for this host's
|
||||
architecture, when the manifest records it.
|
||||
enablesTools:
|
||||
type: array
|
||||
items:
|
||||
|
||||
@@ -51,7 +51,7 @@ export async function verifyPassword(password: string, stored: string): Promise<
|
||||
|
||||
/**
|
||||
* Fixed-cost hash used to equalize login timing for usernames that don't
|
||||
* exist (or have no local password). Computed once per process and cached --
|
||||
* exist (or have no local password). Computed once per process and cached;
|
||||
* without this, a login attempt for an unknown username returns as soon as
|
||||
* the user lookup misses, while a wrong password for a real user waits on a
|
||||
* full scrypt run. That gap is a timing side-channel an attacker can use to
|
||||
|
||||
@@ -74,6 +74,11 @@ function startInstall(bundleId: string, jobId: string): void {
|
||||
const installStartTime = Date.now();
|
||||
|
||||
void (async () => {
|
||||
// Mark the install as started right away: a zero-percent frame claims the
|
||||
// progress slot and clears any stale error left by a previous failed
|
||||
// attempt of this bundle, so a retry never shows the old failure.
|
||||
setInstallProgress(bundleId, { percent: 0, stage: "" }, null);
|
||||
|
||||
// Hold the venv lock across the whole install so no AI tool job loads
|
||||
// native libs from the venv while pip is rewriting them (that segfaults
|
||||
// the sidecar). This awaits any in-flight AI job before the installer
|
||||
@@ -87,6 +92,21 @@ function startInstall(bundleId: string, jobId: string): void {
|
||||
}
|
||||
};
|
||||
|
||||
// A failed spawn fires BOTH "error" and "close", so both handlers funnel
|
||||
// their teardown through this once-guard. Without it the second event
|
||||
// would release the file lock and active slot that pump() just handed to
|
||||
// the next queued bundle, letting two installers run into the same venv
|
||||
// at once (the corruption the lock exists to prevent).
|
||||
let finalized = false;
|
||||
const finalizeOnce = (): boolean => {
|
||||
if (finalized) return false;
|
||||
finalized = true;
|
||||
releaseVenvOnce();
|
||||
releaseInstallLock();
|
||||
clearActive();
|
||||
return true;
|
||||
};
|
||||
|
||||
const child = spawn(pythonPath, [scriptPath, bundleId, manifestPath, modelsDir], {
|
||||
stdio: ["ignore", "pipe", "pipe"],
|
||||
env: {
|
||||
@@ -139,15 +159,12 @@ function startInstall(bundleId: string, jobId: string): void {
|
||||
});
|
||||
|
||||
child.on("close", (code) => {
|
||||
releaseVenvOnce();
|
||||
releaseInstallLock();
|
||||
clearActive();
|
||||
pump();
|
||||
if (!finalizeOnce()) return;
|
||||
|
||||
if (code === 0) {
|
||||
invalidateCache();
|
||||
shutdownDispatcher();
|
||||
setInstallProgress(null, null, null);
|
||||
setInstallProgress(bundleId, null, null);
|
||||
updateSingleFileProgress({ jobId, phase: "complete", percent: 100, stage: "Complete" });
|
||||
trackEvent(ANALYTICS_EVENTS.AI_BUNDLE_ACTION, {
|
||||
bundle_id: bundleId,
|
||||
@@ -195,16 +212,19 @@ function startInstall(bundleId: string, jobId: string): void {
|
||||
setInstallProgress(bundleId, null, errorMsg);
|
||||
updateSingleFileProgress({ jobId, phase: "failed", percent: 0, error: errorMsg });
|
||||
}
|
||||
|
||||
// Record the outcome BEFORE starting the next install, so the next
|
||||
// bundle's first progress frame cannot race with (or be wiped by) this
|
||||
// install's completion/failure bookkeeping.
|
||||
pump();
|
||||
});
|
||||
|
||||
child.on("error", (err) => {
|
||||
releaseVenvOnce();
|
||||
releaseInstallLock();
|
||||
clearActive();
|
||||
pump();
|
||||
if (!finalizeOnce()) return;
|
||||
const errorMsg = `Failed to spawn install process: ${err.message}`;
|
||||
setInstallProgress(bundleId, null, errorMsg);
|
||||
updateSingleFileProgress({ jobId, phase: "failed", percent: 0, error: errorMsg });
|
||||
pump();
|
||||
});
|
||||
})();
|
||||
}
|
||||
|
||||
@@ -48,16 +48,25 @@ export function registerCompare(app: FastifyInstance) {
|
||||
|
||||
try {
|
||||
const imageHandler = inputHandlerFor("image");
|
||||
bufferA = (
|
||||
await imageHandler.prepare(bufferA, filenameA, {
|
||||
scratchDir: tmpdir(),
|
||||
})
|
||||
).buffer;
|
||||
bufferB = (
|
||||
await imageHandler.prepare(bufferB, filenameB, {
|
||||
scratchDir: tmpdir(),
|
||||
})
|
||||
).buffer;
|
||||
// Attribute validation failures to the specific upload: with two
|
||||
// inputs, a bare "Invalid image: ..." does not tell the user which of
|
||||
// their files was rejected. Restores the route's pre-migration
|
||||
// "Invalid first/second image: ..." message contract.
|
||||
const prepareInput = async (buffer: Buffer, filename: string, which: string) => {
|
||||
try {
|
||||
return (await imageHandler.prepare(buffer, filename, { scratchDir: tmpdir() })).buffer;
|
||||
} catch (err) {
|
||||
if (err instanceof InputValidationError) {
|
||||
const message = err.message.startsWith("Invalid image")
|
||||
? err.message.replace("Invalid image", `Invalid ${which} image`)
|
||||
: `${err.message} (${which} image)`;
|
||||
throw new InputValidationError(message, err.statusCode, err.details);
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
bufferA = await prepareInput(bufferA, filenameA, "first");
|
||||
bufferB = await prepareInput(bufferB, filenameB, "second");
|
||||
|
||||
// Normalize both to same size for comparison
|
||||
const metaA = await sharp(bufferA).metadata();
|
||||
|
||||
@@ -12,6 +12,8 @@ import { sanitizeFilename } from "../../lib/filename.js";
|
||||
import { decodeToSharpCompat, needsCliDecode } from "../../lib/format-decoders.js";
|
||||
import { decodeHeic } from "../../lib/heic-converter.js";
|
||||
import { putObject } from "../../lib/object-storage.js";
|
||||
import { InputValidationError } from "../../modality/contract.js";
|
||||
import { inputHandlerFor } from "../../modality/input-handler.js";
|
||||
import { registerToolProcessFn } from "../tool-factory.js";
|
||||
|
||||
const settingsSchema = z.object({
|
||||
@@ -59,37 +61,25 @@ export function registerContentAwareResize(app: FastifyInstance) {
|
||||
return reply.status(400).send({ error: "No image file provided" });
|
||||
}
|
||||
|
||||
const validation = await validateImageBuffer(fileBuffer, filename);
|
||||
if (!validation.valid) {
|
||||
return reply.status(400).send({ error: `Invalid image: ${validation.reason}` });
|
||||
}
|
||||
|
||||
// Decode HEIC/HEIF input (caire can't read HEIF containers)
|
||||
if (validation.format === "heif") {
|
||||
try {
|
||||
fileBuffer = await decodeHeic(fileBuffer);
|
||||
const ext = filename.match(/\.[^.]+$/)?.[0];
|
||||
if (ext) filename = `${filename.slice(0, -ext.length)}.png`;
|
||||
} catch (err) {
|
||||
return reply.status(422).send({
|
||||
error: "Failed to decode HEIC/HEIF file",
|
||||
details: friendlyError(err instanceof Error ? err.message : String(err)),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Decode CLI-decoded formats (RAW, TGA, PSD, EXR, HDR)
|
||||
if (needsCliDecode(validation.format)) {
|
||||
try {
|
||||
fileBuffer = await decodeToSharpCompat(fileBuffer, validation.format);
|
||||
const ext = filename.match(/\.[^.]+$/)?.[0];
|
||||
if (ext) filename = `${filename.slice(0, -ext.length)}.png`;
|
||||
} catch (err) {
|
||||
return reply.status(422).send({
|
||||
error: `Failed to decode ${validation.format} file`,
|
||||
details: friendlyError(err instanceof Error ? err.message : String(err)),
|
||||
});
|
||||
// Shared image input chain (validate, HEIC/RAW decode with filename
|
||||
// rewrite, SVG sanitize, AVIF probe, autoOrient): the same handler the
|
||||
// factory-based image routes use, replacing an inline copy that had
|
||||
// already drifted (it never sanitized SVG or passed the file extension
|
||||
// to the RAW decoder).
|
||||
try {
|
||||
const prepared = await inputHandlerFor("image").prepare(fileBuffer, filename, {
|
||||
scratchDir: tmpdir(),
|
||||
});
|
||||
fileBuffer = prepared.buffer;
|
||||
filename = prepared.filename;
|
||||
} catch (err) {
|
||||
if (err instanceof InputValidationError) {
|
||||
return reply.status(err.statusCode).send({ error: err.message, details: err.details });
|
||||
}
|
||||
return reply.status(422).send({
|
||||
error: "Failed to prepare image",
|
||||
details: friendlyError(err instanceof Error ? err.message : String(err)),
|
||||
});
|
||||
}
|
||||
|
||||
// Validate settings
|
||||
@@ -124,9 +114,6 @@ export function registerContentAwareResize(app: FastifyInstance) {
|
||||
"Starting content-aware resize",
|
||||
);
|
||||
|
||||
// Auto-orient to fix EXIF rotation before seam carving
|
||||
fileBuffer = await autoOrient(fileBuffer);
|
||||
|
||||
const jobId = randomUUID();
|
||||
const scratchDir = join(tmpdir(), "snapotter-scratch", jobId);
|
||||
await mkdir(scratchDir, { recursive: true });
|
||||
|
||||
@@ -64,8 +64,19 @@ export function registerEmbedSubtitles(app: FastifyInstance) {
|
||||
"0:v:0",
|
||||
"-map",
|
||||
"0:a?",
|
||||
// The new subtitle is mapped BEFORE the source's existing subtitle
|
||||
// tracks so it is always output subtitle stream s:0, which the
|
||||
// language tag below targets.
|
||||
"-map",
|
||||
"1:0",
|
||||
// Preserve subtitle tracks already in the source (re-encoded to the
|
||||
// container's text codec, matching the old `-map 0` behavior).
|
||||
// Data streams stay unmapped on purpose: MPEG data tracks such as
|
||||
// teletext cannot be remuxed into mp4/mkv and fail the whole job.
|
||||
"-map",
|
||||
"0:s?",
|
||||
// MKV can carry attachment streams (embedded fonts); MP4 cannot.
|
||||
...(toMp4 ? [] : ["-map", "0:t?"]),
|
||||
...(reencodeInputStreams
|
||||
? [...videoEncodeArgsForContainer(outExt), ...audioEncodeArgsForContainer(outExt)]
|
||||
: ["-c:v", "copy", "-c:a", "copy"]),
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { tmpdir } from "node:os";
|
||||
import type { FastifyInstance } from "fastify";
|
||||
import sharp from "sharp";
|
||||
import { z } from "zod";
|
||||
import { autoOrient } from "../../lib/auto-orient.js";
|
||||
import { formatZodErrors } from "../../lib/errors.js";
|
||||
import { validateImageBuffer } from "../../lib/file-validation.js";
|
||||
import { sanitizeFilename } from "../../lib/filename.js";
|
||||
import { decodeToSharpCompat, needsCliDecode } from "../../lib/format-decoders.js";
|
||||
import { decodeHeic } from "../../lib/heic-converter.js";
|
||||
import { putObject } from "../../lib/object-storage.js";
|
||||
import { resolveOutputFormat } from "../../lib/output-format.js";
|
||||
import { decompressSvgz, sanitizeSvg } from "../../lib/svg-sanitize.js";
|
||||
import { InputValidationError } from "../../modality/contract.js";
|
||||
import { inputHandlerFor } from "../../modality/input-handler.js";
|
||||
|
||||
const settingsSchema = z.object({
|
||||
position: z
|
||||
@@ -81,86 +79,35 @@ export function registerWatermarkImage(app: FastifyInstance) {
|
||||
}
|
||||
|
||||
try {
|
||||
const valMain = await validateImageBuffer(mainBuffer, filename);
|
||||
if (!valMain.valid) {
|
||||
return reply.status(400).send({ error: `Invalid image: ${valMain.reason}` });
|
||||
}
|
||||
if (valMain.format === "heif") {
|
||||
try {
|
||||
mainBuffer = await decodeHeic(mainBuffer);
|
||||
} catch (err) {
|
||||
return reply.status(422).send({
|
||||
error: "Failed to decode HEIC file. Ensure libheif-examples is installed.",
|
||||
details: err instanceof Error ? err.message : String(err),
|
||||
});
|
||||
}
|
||||
}
|
||||
if (needsCliDecode(valMain.format)) {
|
||||
try {
|
||||
const ext = filename.split(".").pop()?.toLowerCase();
|
||||
mainBuffer = await decodeToSharpCompat(mainBuffer, valMain.format, ext);
|
||||
} catch {
|
||||
try {
|
||||
await sharp(mainBuffer).metadata();
|
||||
} catch (err) {
|
||||
return reply.status(422).send({
|
||||
error: `Failed to decode ${valMain.format.toUpperCase()} file`,
|
||||
details: err instanceof Error ? err.message : String(err),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
if (valMain.format === "svg") {
|
||||
try {
|
||||
mainBuffer = decompressSvgz(mainBuffer);
|
||||
mainBuffer = sanitizeSvg(mainBuffer);
|
||||
} catch (err) {
|
||||
return reply.status(400).send({
|
||||
error: err instanceof Error ? err.message : "Invalid SVG",
|
||||
});
|
||||
}
|
||||
}
|
||||
mainBuffer = await autoOrient(mainBuffer);
|
||||
// Shared image input chain (validate, HEIC/RAW decode, SVG sanitize,
|
||||
// AVIF probe, autoOrient), the same handler compare/vectorize/compose
|
||||
// use. It also rewrites the filename extension after a decode so the
|
||||
// output name and resolveOutputFormat below stay consistent.
|
||||
const imageHandler = inputHandlerFor("image");
|
||||
const preparedMain = await imageHandler.prepare(mainBuffer, filename, {
|
||||
scratchDir: tmpdir(),
|
||||
});
|
||||
mainBuffer = preparedMain.buffer;
|
||||
filename = preparedMain.filename;
|
||||
|
||||
const valWm = await validateImageBuffer(watermarkBuffer, watermarkFilename);
|
||||
if (!valWm.valid) {
|
||||
return reply.status(400).send({ error: `Invalid watermark image: ${valWm.reason}` });
|
||||
}
|
||||
if (valWm.format === "heif") {
|
||||
try {
|
||||
watermarkBuffer = await decodeHeic(watermarkBuffer);
|
||||
} catch (err) {
|
||||
return reply.status(422).send({
|
||||
error: "Failed to decode watermark (HEIC). Ensure libheif-examples is installed.",
|
||||
details: err instanceof Error ? err.message : String(err),
|
||||
});
|
||||
try {
|
||||
watermarkBuffer = (
|
||||
await imageHandler.prepare(watermarkBuffer, watermarkFilename, {
|
||||
scratchDir: tmpdir(),
|
||||
})
|
||||
).buffer;
|
||||
} catch (err) {
|
||||
// Attribute validation failures to the watermark upload so the user
|
||||
// knows which of the two files was rejected, preserving the route's
|
||||
// established "Invalid watermark image: ..." message contract.
|
||||
if (err instanceof InputValidationError) {
|
||||
const message = err.message.startsWith("Invalid image")
|
||||
? err.message.replace("Invalid image", "Invalid watermark image")
|
||||
: `${err.message} (watermark)`;
|
||||
throw new InputValidationError(message, err.statusCode, err.details);
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
if (needsCliDecode(valWm.format)) {
|
||||
try {
|
||||
watermarkBuffer = await decodeToSharpCompat(watermarkBuffer, valWm.format);
|
||||
} catch {
|
||||
try {
|
||||
await sharp(watermarkBuffer).metadata();
|
||||
} catch (err) {
|
||||
return reply.status(422).send({
|
||||
error: `Failed to decode watermark (${valWm.format.toUpperCase()})`,
|
||||
details: err instanceof Error ? err.message : String(err),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
if (valWm.format === "svg") {
|
||||
try {
|
||||
watermarkBuffer = decompressSvgz(watermarkBuffer);
|
||||
watermarkBuffer = sanitizeSvg(watermarkBuffer);
|
||||
} catch (err) {
|
||||
return reply.status(400).send({
|
||||
error: err instanceof Error ? err.message : "Invalid SVG (watermark)",
|
||||
});
|
||||
}
|
||||
}
|
||||
watermarkBuffer = await autoOrient(watermarkBuffer);
|
||||
|
||||
const mainImage = sharp(mainBuffer);
|
||||
const mainMeta = await mainImage.metadata();
|
||||
@@ -242,6 +189,9 @@ export function registerWatermarkImage(app: FastifyInstance) {
|
||||
processedSize: result.length,
|
||||
});
|
||||
} catch (err) {
|
||||
if (err instanceof InputValidationError) {
|
||||
return reply.status(err.statusCode).send({ error: err.message, details: err.details });
|
||||
}
|
||||
return reply.status(422).send({
|
||||
error: "Processing failed",
|
||||
details: err instanceof Error ? err.message : "Image processing failed",
|
||||
|
||||
Reference in New Issue
Block a user