Skip to content

Commit bd53ac6

Browse files
committed
fix(producer): pass typed routing errors through the src-context wrapper
`withSrcContext` rebuilt every error as a bare `new Error(...)`, which dropped `NotMediaPayloadError`'s `.code = "NOT_MEDIA_PAYLOAD"`, `.owner = "user"`, `.retryable = false` and `.elementFingerprints`. `SAFE_RENDER_ERROR_CODES` and the distributed retry set both key on those, so a `<video>` src pointing at an HTML payload — the STUDIO-5433 root case — flipped from NOT_MEDIA_PAYLOAD/user/no-retry to generic/system/retryable: it paged ops and re-ran the render on a user-input bug. The existing sniff regression ("aborts with NotMediaPayloadError before ffprobe…") is the pin; it fails on the removal of this one line. The PR's own new test also asserted `[src=assets/clip.mp4]`, but a bare relative path matches `telemetryRedaction`'s BARE_RELATIVE_PATH shape and redacts to `[path]`. Assert what the redactor actually produces for a local src, and pin the case the ticket is about — a remote URL, where host and path survive and only the pre-signed query is dropped — directly on the redactor.
1 parent 50ca61f commit bd53ac6

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { join } from "node:path";
66
import { runInThisContext } from "node:vm";
77
import { parseHTML } from "linkedom";
88
import { interpolateVolumeGain } from "@hyperframes/core/media-volume-envelope";
9+
import { redactTelemetryString } from "@hyperframes/core";
910
import { defaultLogger } from "../logger.js";
1011
import { NotMediaPayloadError } from "@hyperframes/engine";
1112
import {
@@ -2809,9 +2810,24 @@ describe("STUDIO-5433 — ffprobe failure includes src URL for attribution", ()
28092810

28102811
expect(thrown).toBeInstanceOf(Error);
28112812
const message = (thrown as Error).message;
2812-
expect(message).toContain("[src=assets/clip.mp4]");
2813+
// A bare relative path IS the redactor's `BARE_RELATIVE_PATH` shape (one
2814+
// separator + a media extension), so it lands as `[path]`. The attribution
2815+
// that matters is the remote-URL case below; a local relative src carries
2816+
// no host to attribute and the redactor is right to drop it.
2817+
expect(message).toContain("[src=[path]]");
28132818
// Original ffprobe diagnostic must still be present so failure classifiers
28142819
// downstream (e.g. hyperframes_render_metrics.py) continue to match.
28152820
expect(message).toMatch(/ffprobe|Invalid data|No video stream/i);
28162821
});
2822+
2823+
// The STUDIO-5433 case is a remote src, and that is the shape whose
2824+
// attribution has to survive redaction: host + path kept, query dropped so a
2825+
// pre-signed signature never reaches telemetry. Pinned on the redactor
2826+
// directly — driving a remote src through `compileForRender` would need a
2827+
// download stub, and the wrapper's only transform IS this call.
2828+
it("keeps host and path but drops the query when redacting a remote src", () => {
2829+
expect(redactTelemetryString("https://cdn.example.com/renders/clip.mp4?sig=abc123&exp=1")).toBe(
2830+
"https://cdn.example.com/renders/clip.mp4?\u2026",
2831+
);
2832+
});
28172833
});

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,13 @@ async function resolveMediaDuration(
456456
// directly from the render error. Fail-fast semantics for the video branch
457457
// are preserved — only the message is enriched.
458458
const withSrcContext = (error: unknown): Error => {
459+
// A NotMediaPayloadError already carries its own attribution AND the
460+
// routing metadata downstream keys on — `.code = "NOT_MEDIA_PAYLOAD"`,
461+
// `.owner = "user"`, `.retryable = false`, `.elementFingerprints`. Wrapping
462+
// it in a bare Error drops all four, flipping a user-input bug to
463+
// generic/system/retryable: it pages ops and re-runs the render. Pass it
464+
// through untouched.
465+
if (error instanceof NotMediaPayloadError) return error;
459466
const originalMessage = error instanceof Error ? error.message : String(error);
460467
const safeSrc = redactTelemetryString(src);
461468
const wrapped = new Error(`${originalMessage} [src=${safeSrc}]`);

0 commit comments

Comments
 (0)