affaan-m/ECC · error · ValueError
reference probe duration must be finite and positive
Error message
reference probe duration must be finite and positive
What it means
_validate_probe requires the probe result's "duration" field to be a finite, non-boolean real number strictly greater than zero. This error is raised when duration is missing (None), not a number, a bool, NaN/inf, or <= 0. Duration anchors all temporal validation (sample_times, scene_changes, style sample times must fall within it), so an invalid duration makes the entire probe payload unusable.
Solutions
- Ensure the probe callable always returns a positive finite "duration"; supply a measured or fallback duration for media lacking container metadata.
- Only feed video/3d media with real duration metadata into the workflow; check `ffprobe -show_format` reports a duration > 0 before running.
- For still images used as references, wrap them in a container or have the custom probe return an explicit nominal duration (e.g. 1.0).
- Fix custom probes/tests to include "duration" in the returned dict rather than omitting it.
- Handle 'N/A' duration strings explicitly instead of relying on `or 0`, which silently converts them to the rejected 0.0.
Example fix
// before
video = {} # image: no video stream
duration = float(video.get("duration") or payload.get("format", {}).get("duration") or 0) # -> 0.0
// after
duration = float(video.get("duration") or payload.get("format", {}).get("duration") or 0)
if not math.isfinite(duration) or duration <= 0:
raise MediaToolUnavailable(f"source has no measurable duration: {path}") Defensive patterns
Strategy: validation
Validate before calling
import json, subprocess
def reference_has_positive_duration(path) -> bool:
out = subprocess.run(
["ffprobe", "-v", "error", "-show_format", "-of", "json", str(path)],
capture_output=True, text=True, check=True,
).stdout
duration = json.loads(out).get("format", {}).get("duration")
try:
return duration is not None and float(duration) > 0
except (TypeError, ValueError):
return False
# preflight every reference in the contract before run_workflow Type guard
def has_valid_duration(measured: dict) -> bool:
import math
d = measured.get("duration")
return (
isinstance(d, (int, float))
and not isinstance(d, bool)
and math.isfinite(d)
and float(d) > 0
) Try / catch
try:
receipt = run_workflow("contract.json", "out/", probe=my_probe)
except ValueError as e:
if "duration must be finite and positive" in str(e):
logger.error("reference has no measurable duration; supply a probe with an explicit positive duration")
receipt = run_workflow("contract.json", "out/", probe=probe_with_fallback_duration)
else:
raise Prevention
- Preflight each reference with ffprobe and confirm duration > 0 before running the workflow
- Do not feed still images or live streams lacking duration metadata unless your probe supplies a nominal duration
- Never rely on `value or 0` fallbacks for duration; treat missing metadata as a hard input error
- Always include an explicit "duration" key in custom probe return values
When it happens
Trigger: run_workflow() -> _validate_probe(measured) where measured lacks "duration", or measured["duration"] is None/0/negative/nan — e.g. a probe on an image-like or stream file where ffprobe reports no duration and probe_media's `or 0` fallback yields 0.0, or a custom probe forgets the field.
Common situations: Probing a still image or a live/raw stream with no duration metadata; a custom probe returning an empty dict; ffprobe output with 'duration': 'N/A' coerced through `or 0`; audio-only files where the video stream lacks duration and format.duration is also absent.
Understand the failure class
Background: "invalid duration" / "failed to parse duration": why your timeout, interval, or TTL string is rejected and which formats each library accepts — this error's family across 32 libraries.
Related errors
- clip ( ) has non-positive duration
- clip ( ) has non-positive duration
- clip ( ) has non-positive duration
- genre has invalid total duration
- receipt reference has an invalid finite source duration
AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16).
Data as JSON: /api/errors/e840139a2b3d1d1b.
Report an issue: GitHub.
Appendix: source
Thrown at skills/taste-application/scripts/tasteforge/workflow.py:145
def require_finite_evidence(value: Any) -> None:
if isinstance(value, bool):
raise ValueError( # noqa: TRY004 - one bounded invalid-media error family
"reference probe numeric evidence must be finite real values"
)
if isinstance(value, (int, float)):
if not math.isfinite(value):
raise ValueError("reference probe numeric evidence must be finite real values")
elif isinstance(value, dict):
for nested in value.values():
require_finite_evidence(nested)
elif isinstance(value, list):
for nested in value:
require_finite_evidence(nested)
require_finite_evidence(measured)
duration = measured.get("duration")
if not _finite_real(duration):
raise ValueError("reference probe duration must be finite and positive")
duration = cast(float, duration)
if float(duration) <= 0:
raise ValueError("reference probe duration must be finite and positive")
for field in ("sample_times", "scene_changes"):
values = measured.get(field, [])
if not isinstance(values, list) or any(
not _finite_real(value) or float(value) < 0 or float(value) > float(duration)
for value in values
):
raise ValueError(f"reference probe {field} must contain finite in-duration times")
samples = measured.get("style_samples", [])
if not isinstance(samples, list) or any(
not isinstance(sample, dict)
or not _finite_real(sample.get("time"))
or float(cast(float, sample["time"])) < 0
or float(cast(float, sample["time"])) > float(duration)
for sample in samples
):View on GitHub (pinned to 8321021c54)