Skip to content

Commit 50ca61f

Browse files
vanceingallsclaude
andcommitted
fix(producer): attach src URL to ffprobe failures for compile-phase attribution (STUDIO-5433)
Wrap the video-branch `extractMediaMetadata` and `probeMediaProfile` calls in `resolveMediaDuration` (`packages/producer/src/services/htmlCompiler.ts`) with a `withSrcContext` helper that re-throws with the remote `src` appended as `[src=<url>]`. The URL is passed through `redactTelemetryString` first so pre-signed URL signatures never reach telemetry. STUDIO-5433 — enterprise customer `[email protected]` was blocked from generating AI Studio videos, surfacing in Datadog as `[FFmpeg] ffprobe exit with code 1: [mov,mp4,m4a,3gp,3g2,mj2 @ 0x...] moov atom not found\n[input]: Invalid data found when processing input`. `runFfprobe` at `engine/utils/ffprobe.ts:74-79` intentionally redacts the local `filePath` from the error (see `redactFfprobeInput` — same file, lines 13-35), so the failure carries no attribution and identifying the offending source requires dumping the Temporal activity history for the workflow. That dump is expensive-per-occurrence and blocks debugging on operator availability. The demuxer signature (`mov,mp4,m4a,3gp,3g2,mj2`) tells us the file is MOV/MP4-family, and the workflow_id tells us which HyperFrames composition element failed — but the *actual URL* that ffprobe was handed is lost. This change surfaces the URL so the next occurrence is diagnosable directly from the render error in Datadog, without a Temporal history dump. Preserves fail-fast semantics: the video branch still throws (aborts the compile), unlike the audio branch's deliberate graceful-degrade to `duration=0`. Only the error *message* is enriched; the control flow is unchanged. 1. `packages/producer/src/services/htmlCompiler.ts` - New `withSrcContext(error)` helper inside `resolveMediaDuration` that wraps `error.message` with `[src=<redactTelemetryString(src)>]` and preserves the original stack. - Video-branch `probeMediaProfile` catch re-throws via `withSrcContext` (was: bare `throw error`). - Video-branch `extractMediaMetadata` newly wrapped in try/catch that re-throws via `withSrcContext` (was: uncaught, so the caller saw the bare `[input]`-redacted ffprobe message). - Adds `redactTelemetryString` import from `@hyperframes/core` (already re-exported at `packages/core/src/index.ts:255`). 2. `packages/producer/src/services/htmlCompiler.test.ts` - New `describe("STUDIO-5433 — ffprobe failure includes src URL for attribution")` block with a `compileForRender` integration test: writes a 0-byte `assets/clip.mp4`, references it from an `<video src>` tag, asserts the thrown error message contains `[src=assets/clip.mp4]` AND still carries the original ffprobe diagnostic so downstream failure classifiers continue to match. - [x] Repro locally: 0-byte mp4 → `compileForRender` → error message contains `[src=assets/clip.mp4]` (test above). - [x] Preserves fail-fast semantics — video branch still throws (assertion on thrown error). - [ ] Focused CI must pass; hosted CI to follow. - [ ] Follow-up (separate PR pending URL recovery): identify the writer that produces the actual failing derivative and add `_probe_section_integrity` fail-closed at the write site (the durable fix — this PR is diagnosability defense-in-depth). <!-- pr-check:enterprise-ff:start --> - [x] This change is not behind a feature flag (small diagnostic improvement on an existing error path; preserves failure semantics unchanged). - [ ] This change is behind a feature flag <!-- pr-check:enterprise-ff:end --> <!-- pr-check:ui-impact --> - [x] <!-- pr-opt:no-ui-impact --> No UI impact — enriches a producer-worker error message read only in Datadog. Co-Authored-By: Claude Opus 4.7 <[email protected]>
1 parent a897806 commit 50ca61f

2 files changed

Lines changed: 77 additions & 2 deletions

File tree

‎packages/producer/src/services/htmlCompiler.test.ts‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2763,3 +2763,55 @@ describe("duplicate media ids across nested compositions", () => {
27632763
expect(compiled.audios[1]).toMatchObject({ start: 3, end: 6, mediaStart: 50 });
27642764
});
27652765
});
2766+
2767+
describe("STUDIO-5433 — ffprobe failure includes src URL for attribution", () => {
2768+
function writeCorruptVideoProject(videoSrc: string, assetBytes: Buffer): string {
2769+
const projectDir = mkdtempSync(join(tmpdir(), "hf-studio-5433-"));
2770+
mkdirSync(join(projectDir, "assets"), { recursive: true });
2771+
writeFileSync(join(projectDir, "assets", "clip.mp4"), assetBytes);
2772+
writeFileSync(
2773+
join(projectDir, "index.html"),
2774+
`<!DOCTYPE html>
2775+
<html>
2776+
<body>
2777+
<div id="root" data-composition-id="root" data-start="0" data-duration="4" data-width="640" data-height="360">
2778+
<video
2779+
id="clip"
2780+
src="${videoSrc}"
2781+
data-start="0"
2782+
data-duration="4"
2783+
data-width="640"
2784+
data-height="360"
2785+
></video>
2786+
</div>
2787+
<script>
2788+
window.__timelines = window.__timelines || {};
2789+
window.__timelines["root"] = { duration: () => 4 };
2790+
</script>
2791+
</body>
2792+
</html>`,
2793+
);
2794+
return projectDir;
2795+
}
2796+
2797+
it("wraps the ffprobe error with [src=<relative-path>] when the local video is corrupt", async () => {
2798+
// 0-byte mp4 — ffprobe reports "Invalid data found when processing input",
2799+
// the same class as the STUDIO-5433 moov failure. Fail-fast semantics remain
2800+
// (video branch throws, unlike audio's graceful-degrade to duration=0).
2801+
const projectDir = writeCorruptVideoProject("assets/clip.mp4", Buffer.alloc(0));
2802+
2803+
let thrown: unknown;
2804+
try {
2805+
await compileForRender(projectDir, join(projectDir, "index.html"), projectDir);
2806+
} catch (error) {
2807+
thrown = error;
2808+
}
2809+
2810+
expect(thrown).toBeInstanceOf(Error);
2811+
const message = (thrown as Error).message;
2812+
expect(message).toContain("[src=assets/clip.mp4]");
2813+
// Original ffprobe diagnostic must still be present so failure classifiers
2814+
// downstream (e.g. hyperframes_render_metrics.py) continue to match.
2815+
expect(message).toMatch(/ffprobe|Invalid data|No video stream/i);
2816+
});
2817+
});

‎packages/producer/src/services/htmlCompiler.ts‎

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
isNonRelativeUrl,
2424
parseStrictFiniteTimingNumber,
2525
readMediaStart,
26+
redactTelemetryString,
2627
resolveNaturalMediaTimelineDurationFromValues,
2728
type ResolvedDuration,
2829
type UnresolvedElement,
@@ -444,6 +445,24 @@ async function resolveMediaDuration(
444445
return { duration: null, resolvedPath: filePath };
445446
}
446447

448+
// STUDIO-5433: attach the remote `src` to any ffprobe failure surfaced from
449+
// this branch. `extractMediaMetadata` → `runFfprobe` intentionally redacts
450+
// its local `filePath` out of the error message (see
451+
// engine/utils/ffprobe.ts::redactFfprobeInput), so a bare `moov atom not
452+
// found` in Datadog carries no attribution and requires a Temporal history
453+
// dump to identify the offending source. Re-throwing with the `src`
454+
// (query-string redacted via `redactTelemetryString` so pre-signed URL
455+
// signatures never reach telemetry) makes the next occurrence diagnosable
456+
// directly from the render error. Fail-fast semantics for the video branch
457+
// are preserved — only the message is enriched.
458+
const withSrcContext = (error: unknown): Error => {
459+
const originalMessage = error instanceof Error ? error.message : String(error);
460+
const safeSrc = redactTelemetryString(src);
461+
const wrapped = new Error(`${originalMessage} [src=${safeSrc}]`);
462+
if (error instanceof Error && error.stack) wrapped.stack = error.stack;
463+
return wrapped;
464+
};
465+
447466
return withMediaProbeSlot(async () => {
448467
let profile: MediaProbeProfile;
449468
try {
@@ -471,13 +490,17 @@ async function resolveMediaDuration(
471490
}
472491
return { duration: null, resolvedPath: filePath };
473492
}
474-
throw error;
493+
throw withSrcContext(error);
475494
}
476495
assertAssetMediaTypeProfile(tagName === "video" ? "video" : "audio", profile, elementIdentity);
477496

478497
let metadata: { durationSeconds: number };
479498
if (tagName === "video") {
480-
metadata = await extractMediaMetadata(filePath);
499+
try {
500+
metadata = await extractMediaMetadata(filePath);
501+
} catch (error) {
502+
throw withSrcContext(error);
503+
}
481504
} else {
482505
try {
483506
metadata = await extractAudioMetadata(filePath);

0 commit comments

Comments
 (0)