fix(producer): enforce video extraction failures by default (#3372) (#3526)

The extraction failure policy defaulted to "off", silently swallowing
per-source errors. The plumbing to surface them (typed error, retryable
classification, caller throw) was fully built but gated behind an
env-var opt-in. Flip the default to "enforce" so extraction failures
fail the render instead of producing misleading coverage aborts.

Set HF_VIDEO_EXTRACTION_FAILURE_MODE=off to restore the old behavior.

Co-authored-by: Miguel Ángel <miguel.sierra@heygen.com>
This commit is contained in:
miga-heygen
2026-08-28 00:31:37 +00:00
committed by GitHub
co-authored by Miguel Ángel
parent 9eb84c91b6
commit 4d87f8bbae
2 changed files with 15 additions and 8 deletions
@@ -205,14 +205,14 @@ describe("shouldCopyExtractedFrames", () => {
});
describe("resolveVideoExtractionPolicy", () => {
it("preserves stable behavior by default", () => {
it("enforces extraction failures by default (#3372)", () => {
expect(resolveVideoExtractionPolicy({})).toEqual({
failureMode: "off",
failureMode: "enforce",
maxTransientRetries: 0,
});
});
it("allows only the bounded candidate rollout values", () => {
it("allows explicit opt-out or observe mode", () => {
expect(
resolveVideoExtractionPolicy({
HF_VIDEO_EXTRACTION_FAILURE_MODE: "observe",
@@ -221,10 +221,15 @@ describe("resolveVideoExtractionPolicy", () => {
).toEqual({ failureMode: "observe", maxTransientRetries: 1 });
expect(
resolveVideoExtractionPolicy({
HF_VIDEO_EXTRACTION_FAILURE_MODE: "unexpected",
HF_VIDEO_EXTRACTION_MAX_RETRIES: "1",
HF_VIDEO_EXTRACTION_FAILURE_MODE: "off",
}),
).toEqual({ failureMode: "off", maxTransientRetries: 0 });
expect(
resolveVideoExtractionPolicy({
HF_VIDEO_EXTRACTION_FAILURE_MODE: "enforce",
HF_VIDEO_EXTRACTION_MAX_RETRIES: "1",
}),
).toEqual({ failureMode: "enforce", maxTransientRetries: 1 });
});
});
@@ -131,15 +131,17 @@ export interface VideoExtractionPolicy {
}
/**
* Candidate-lane rollout controls. Stable behavior remains unchanged unless
* explicitly enabled in the producer environment.
* Extraction failure policy. Defaults to `enforce` so per-source errors
* surface as render failures instead of being silently swallowed (#3372).
* Set `HF_VIDEO_EXTRACTION_FAILURE_MODE=off` to restore the old silent
* behavior, or `observe` to log without failing.
*/
export function resolveVideoExtractionPolicy(
env: Readonly<Record<string, string | undefined>> = process.env,
): VideoExtractionPolicy {
const rawMode = env.HF_VIDEO_EXTRACTION_FAILURE_MODE?.trim().toLowerCase();
const failureMode: VideoExtractionFailureMode =
rawMode === "observe" || rawMode === "enforce" ? rawMode : "off";
rawMode === "observe" || rawMode === "off" ? rawMode : "enforce";
const maxTransientRetries =
failureMode !== "off" && env.HF_VIDEO_EXTRACTION_MAX_RETRIES?.trim() === "1" ? 1 : 0;
return { failureMode, maxTransientRetries };