mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-10 22:20:14 +00:00
fix(producer): classify JSON error bodies as non-media sources too
A source that answers with a JSON error body still reached ffprobe and
produced `moov atom not found`. Replicate returns
`{"detail": "requested file not found"}` for a dead asset, and a gateway
in front of it can relay that body with a success status.
The sniff now treats `<`, `{`, or `[` as the opening byte of a text
document. No supported container starts with any of them, so this is the
same trade as before: three bytes instead of an allowlist that grows one
entry per payload shape observed in production.
Renamed accordingly, since the class now covers JSON as well as markup:
MARKUP_NOT_MEDIA -> NOT_MEDIA_PAYLOAD, MarkupNotMediaError ->
NotMediaPayloadError, markupPayload.ts -> notMediaPayload.ts. Registry
entries in the Lambda name map, the CDK and SAM plan lists, the Cloud Run
set, and SAFE_RENDER_ERROR_CODES move with it.
Also documents the reachability boundary on the error class: only a 2xx
response gets here. `downloadToTemp` rejects 404/410 as `http_not_found`
before writing a byte, and every ffprobe input is local because
videoFrameExtractor downloads http srcs first. So the shapes this
classifies are soft-404 and interstitial HTML, S3/CloudFront error
documents, and JSON API error bodies -- each served with a success
status. A genuine 404 surfaces as a download failure, not as this error.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
f3689c1481
commit
349c066a83
@@ -120,7 +120,7 @@ describe("processCompositionAudio", () => {
|
||||
// probe entirely when the element carries an authored duration, and used to
|
||||
// surface as `prepare/ffmpeg_failed` with owner "system" — an authoring bug
|
||||
// paged as a platform fault, after every frame had already been captured.
|
||||
it("classifies a markup audio source as a user-owned invalid media source", async () => {
|
||||
it("classifies a document audio source as a user-owned invalid media source", async () => {
|
||||
const baseDir = mkdtempSync(join(tmpdir(), "hf-audio-base-"));
|
||||
const workDir = mkdtempSync(join(tmpdir(), "hf-audio-work-"));
|
||||
tempDirs.push(baseDir, workDir);
|
||||
|
||||
@@ -9,7 +9,7 @@ import { closeSync, existsSync, mkdirSync, mkdtempSync, openSync, rmSync, writeF
|
||||
import { join, dirname } from "path";
|
||||
import { parseHTML } from "linkedom";
|
||||
import { extractAudioMetadata } from "../utils/ffprobe.js";
|
||||
import { isMarkupPayload } from "../utils/markupPayload.js";
|
||||
import { isNotMediaPayload } from "../utils/notMediaPayload.js";
|
||||
import { downloadToTemp, isHttpUrl } from "../utils/urlDownloader.js";
|
||||
import { DEFAULT_CONFIG, type EngineConfig } from "../config.js";
|
||||
import { formatFfmpegError, runFfmpeg, type RunFfmpegResult } from "../utils/runFfmpeg.js";
|
||||
@@ -734,13 +734,13 @@ export async function processCompositionAudio(
|
||||
return;
|
||||
}
|
||||
|
||||
// STUDIO-5433: an audio src that resolved to an HTML/XML document (an
|
||||
// STUDIO-5433: an audio src that resolved to a text document (an
|
||||
// unresolved nested-composition preview URL, or a 403/404 body served
|
||||
// with a 200) never reaches the probe below when the element carries an
|
||||
// authored duration or `loop`. It then fails inside ffmpeg as
|
||||
// `prepare/ffmpeg_failed` with owner "system" — an authoring bug paged
|
||||
// as a platform fault, after every frame has already been captured.
|
||||
if (await isMarkupPayload(srcPath)) {
|
||||
if (await isNotMediaPayload(srcPath)) {
|
||||
failures.push({
|
||||
stage: "source",
|
||||
reason: "invalid_media",
|
||||
@@ -748,7 +748,7 @@ export async function processCompositionAudio(
|
||||
retryable: false,
|
||||
elementId: element.id,
|
||||
detail: boundedDetail(
|
||||
`Audio element ${element.id} source is a markup document (HTML/XML), not media`,
|
||||
`Audio element ${element.id} source is a text document (HTML/XML/JSON), not media`,
|
||||
),
|
||||
});
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user