fix(api): drop app-logger import from media-input; update stale errors mock

The full unit suite surfaced two issues from earlier commits on this branch. (1) Importing the app logger into media-input.ts pulled logger.ts -- which builds its pino file transport at module load via join(env.LOG_DIR, ...) -- into the unit-test import graph, throwing at collection time wherever LOG_DIR is unset (integration tests set it; unit tests do not). A low-level modality handler should not depend on the app logger, and a corrupt upload is an expected user error, so drop the import and keep the clean validation message. (2) tool-factory-route.test.ts mocked errors.js without the new friendlyError export; add it.
This commit is contained in:
SnapOtter
2026-06-17 14:28:41 +08:00
parent 9c250d244f
commit c483897452
2 changed files with 5 additions and 4 deletions
+4 -4
View File
@@ -4,7 +4,6 @@ import { extname, join } from "node:path";
import { probeMedia } from "@snapotter/media-engine";
import { SUBTITLE_INPUTS } from "@snapotter/shared";
import { env } from "../config.js";
import { logger } from "../lib/logger.js";
import { type InputHandler, InputValidationError, type PreparedInput } from "./contract.js";
export type MediaInputKind = "video" | "audio" | "image" | "subtitle";
@@ -38,9 +37,10 @@ export class MediaInputHandler implements InputHandler {
let info: Awaited<ReturnType<typeof probeMedia>>;
try {
info = await probeMedia(probePath);
} catch (err) {
// Keep the raw ffprobe failure in logs; never surface it to the client.
logger.warn({ err, kind: this.kind }, "media input probe failed");
} catch {
// ffprobe could not parse the upload. Surface a clean message; the raw
// tool error is intentionally not exposed to the client, and a bad
// upload is not a server fault worth logging from this low-level handler.
throw new InputValidationError(
`Unrecognized ${this.kind} file. It may be corrupt or in an unsupported format.`,
);