diegosouzapw/OmniRoute · error
Video extraction broker returned an invalid frame count
Error message
Video extraction broker returned an invalid frame count
What it means
The video-extraction broker's response was valid JSON but failed shape validation in parseBrokerResult(): durationSeconds is not a finite positive number or the frames field is not an array. It indicates the broker process returned truncated/corrupt metadata, not a network failure.
Solutions
- Verify the requested frameCount is > 0 and the video itself is decodable by the broker
- Compare the returned frames array length against the request to detect broker truncation
- Update broker/client together if the result schema changed
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at src/lib/guardrails/videoBridgeBrokerClient.ts:92 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25).
Data as JSON: /api/errors/95664f9435d9aaf1.
Report an issue: GitHub.
Appendix: source
Thrown at src/lib/guardrails/videoBridgeBrokerClient.ts:92
const text = Buffer.concat(
chunks.map((chunk) => Buffer.from(chunk)),
totalBytes
).toString("utf8");
try {
return JSON.parse(text);
} catch {
throw new Error("Video extraction broker returned an invalid response");
}
}
function parseBrokerResult(value: unknown, frameCount: number): BrokerExtractionResult {
const record = value && typeof value === "object" ? (value as Record<string, unknown>) : null;
const durationSeconds = Number(record?.durationSeconds);
if (!Number.isFinite(durationSeconds) || durationSeconds <= 0 || !Array.isArray(record?.frames)) {
throw new Error("Video extraction broker returned invalid metadata");
}
if (record.frames.length < 1 || record.frames.length > frameCount) {
throw new Error("Video extraction broker returned an invalid frame count");
}
const frames = record.frames.map((entry) => {
const frame = entry && typeof entry === "object" ? (entry as Record<string, unknown>) : null;
const timestampSeconds = Number(frame?.timestampSeconds);
const dataUri = typeof frame?.dataUri === "string" ? frame.dataUri : "";
if (
!Number.isFinite(timestampSeconds) ||
timestampSeconds < 0 ||
!/^data:image\/jpeg;base64,[A-Za-z0-9+/=]+$/.test(dataUri)
) {
throw new Error("Video extraction broker returned an invalid frame");
}
return { dataUri, timestampSeconds };
});
const samplingRecord =
record?.sampling && typeof record.sampling === "object"
? (record.sampling as Record<string, unknown>)
: {};View on GitHub (pinned to a179ffed5b)