diegosouzapw/OmniRoute · error · Error

Video frame count must be between 1 and 16

Error message

Video frame count must be between 1 and 16

What it means

Input-validation guard in calculateFrameTimestamps: the requestedFrameCount argument failed one of three checks — not an integer (e.g. 4.5, NaN via Number.isInteger), less than 1, or greater than 16. The caller (frame-uniform sampling) passed an invalid frame count; nothing environmental is wrong.

Solutions

  1. Clamp the requested frame count to the 1..16 range at the API boundary instead of failing
  2. Return a 400 with the allowed range so the client can adjust the request
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/lib/guardrails/videoBridgeRuntime.ts:226 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/d6a73bd4cba08969. Report an issue: GitHub.

Appendix: source

Thrown at src/lib/guardrails/videoBridgeRuntime.ts:226

    expiresAt: now + (options.cacheTtlMs ?? 30_000),
    value,
  };
  return structuredClone(value);
}

export function calculateFrameTimestamps(
  durationSeconds: number,
  requestedFrameCount: number
): number[] {
  if (!Number.isFinite(durationSeconds) || durationSeconds <= 0) {
    throw new Error("Video duration must be positive");
  }
  if (
    !Number.isInteger(requestedFrameCount) ||
    requestedFrameCount < 1 ||
    requestedFrameCount > 16
  ) {
    throw new Error("Video frame count must be between 1 and 16");
  }
  const frameCount = Math.min(requestedFrameCount, Math.max(1, Math.floor(durationSeconds)));
  return Array.from(
    { length: frameCount },
    (_unused, index) => ((index + 0.5) * durationSeconds) / frameCount
  );
}

function normalizeSceneCandidates(
  durationSeconds: number,
  candidates: readonly number[]
): number[] {
  const unique = new Set<number>();
  for (const candidate of candidates) {
    if (!Number.isFinite(candidate) || candidate <= 0 || candidate >= durationSeconds) continue;
    unique.add(Number(candidate.toFixed(3)));
  }
  return [...unique].sort((left, right) => left - right);

View on GitHub (pinned to a179ffed5b)