affaan-m/ECC · error · ContractError
has an invalid finite source duration
Error message
{label} has an invalid finite source duration What it means
_validate_media_time requires the source_duration argument to be a finite, non-boolean real number before validating a media time value against it. The first check raises when source_duration is not a finite int/float (None, string, bool, NaN, inf). This ensures all later numeric comparisons are well-defined.
Solutions
- Ensure the source JSON carries duration as a JSON number, not a string; convert with float() at authoring time.
- Handle None/missing duration by fixing the upstream document before calling the validator.
- Reject non-finite floats (NaN/Inf) when loading the document; they indicate corrupt probe data.
- Sanitize bools out of numeric fields (isinstance(v, bool) check) before validation.
Example fix
// before doc['duration'] = str(ffprobe_seconds) # "12.5" // after doc['duration'] = float(ffprobe_seconds) # 12.5
Defensive patterns
Strategy: type-guard
Validate before calling
import math
def valid_source_duration(v) -> bool:
return isinstance(v, (int, float)) and not isinstance(v, bool) and math.isfinite(v) Type guard
def is_finite_real(v) -> bool:
return isinstance(v, (int, float)) and not isinstance(v, bool) and math.isfinite(v) Try / catch
try:
validate_genre_specs(spec, source_duration=dur)
except ContractError as e:
if 'invalid finite source duration' in str(e):
dur = float(probe['duration']) # repair from probe
else:
raise Prevention
- Store durations as JSON numbers, never strings
- Reject NaN/Infinity at document load time
- Exclude bools from numeric fields (isinstance(v, bool) check)
- Run ffprobe results through a numeric sanitizer before writing manifests
When it happens
Trigger: Calling any validator (validate_genre_specs, validate_effect_recipe, validate_provenance, validate_artifact_receipt, _validate_probe_evidence) with a source_duration of null, a numeric string like "12.5", True, NaN, or Infinity.
Common situations: Probe JSON where the duration field was omitted or left as a string, NaN/Infinity produced by upstream ffmpeg/ffprobe parsing, or bools slipping in from YAML's yes/no mapping to true/false.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Geometry, fps and duration must be finite and positive
- contains a non-finite numeric value
- is outside its source duration
- application bundle differs from its bound evidence
- At least one video is required
AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16).
Data as JSON: /api/errors/b87cc6dc4e3b985c.
Report an issue: GitHub.
Appendix: source
Thrown at skills/taste-application/scripts/tasteforge/contract.py:28
import stat
from pathlib import Path
from typing import Any, cast
_REQUIRED_MODALITIES = {"image", "video", "3d_asset"}
_SIGNATURE_AXES = {"materials", "motion", "composition", "avoid"}
class ContractError(ValueError):
"""The dry-run bundle is incomplete or has lost taste specificity."""
def _is_finite_real(value: Any) -> bool:
return isinstance(value, (int, float)) and not isinstance(value, bool) and math.isfinite(value)
def _validate_media_time(value: Any, source_duration: Any, *, label: str) -> None:
if not _is_finite_real(source_duration):
raise ContractError(f"{label} has an invalid finite source duration")
source_duration = cast(float, source_duration)
if float(source_duration) <= 0:
raise ContractError(f"{label} has an invalid finite source duration")
if (not _is_finite_real(value) or float(value) < 0
or float(value) > float(source_duration)):
raise ContractError(f"{label} is outside its source duration")
def _validate_numeric_evidence(value: Any, *, label: str) -> None:
if isinstance(value, bool):
raise ContractError(f"{label} contains a boolean numeric value")
if isinstance(value, (int, float)):
if not math.isfinite(value):
raise ContractError(f"{label} contains a non-finite numeric value")
elif isinstance(value, dict):
for nested in value.values():
_validate_numeric_evidence(nested, label=label)
elif isinstance(value, list):View on GitHub (pinned to 8321021c54)