affaan-m/ECC · error · ValueError

reference style evidence times must be finite and within…

Error message

reference style evidence times must be finite and within duration

What it means

Each entry of the measured probe's 'style_samples' list must be a dict with a 'time' field that is a finite real number within [0, duration]. _validate_probe raises this when any sample is not a dict, its time is missing/non-numeric/NaN/inf, or the time falls outside the probe duration. It ensures style evidence aligns with the probe timeline.

Solutions

  1. Ensure every style sample is a dict with a numeric finite 'time' key inside [0, duration]
  2. Clamp sample times to the duration or regenerate samples from the actual probe clip
  3. Fix the exporter that produces style_samples to emit {'time': float} entries
  4. Pre-validate with a loop asserting isinstance(s, dict) and math.isfinite(s.get('time', float('nan')))

Example fix

# before
measured['style_samples'] = [{'time': '2.5s'}, {'at': 7.0}]

# after
measured['style_samples'] = [{'time': 2.5}, {'time': 7.0}]
run_workflow(measured)
Defensive patterns

Strategy: validation

Validate before calling

import math
def validate_style_samples(measured):
    dur = float(measured['duration'])
    return all(isinstance(s, dict)
               and isinstance(s.get('time'), (int, float))
               and not isinstance(s.get('time'), bool)
               and math.isfinite(s['time'])
               and 0 <= float(s['time']) <= dur
               for s in measured.get('style_samples', []))

Type guard

def is_style_sample(s) -> bool:
    t = s.get('time') if isinstance(s, dict) else None
    return (isinstance(t, (int, float)) and not isinstance(t, bool)
            and math.isfinite(t))

Try / catch

try:
    run_workflow(measured)
except ValueError as e:
    if 'style evidence times' in str(e):
        print('style_samples must be [{"time": <number in [0, duration>]}]')
    else:
        raise

Prevention

When it happens

Trigger: run_workflow called with style_samples containing e.g. [{'time': '3s'}], [{'time': None}], [{'at': 3.0}] (wrong key), non-dict entries, or a sample time > duration or < 0.

Common situations: Annotating samples with timestamp strings instead of numbers; renaming the 'time' key in an upstream exporter; samples collected from a longer source clip than the probe duration; nulls when frame extraction failed.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16). Data as JSON: /api/errors/a26cb8aa9838a998. Report an issue: GitHub.

Appendix: source

Thrown at skills/taste-application/scripts/tasteforge/workflow.py:164

    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
    ):
        raise ValueError("reference style evidence times must be finite and within duration")
    return float(duration)


class _SafeOutput:
    """Descriptor-bound output tree with no-follow traversal and atomic writes."""

    def __init__(self, root: Path) -> None:
        self._root_fd = -1
        if not hasattr(os, "O_NOFOLLOW") or not hasattr(os, "O_DIRECTORY"):
            raise RuntimeError("secure output requires O_NOFOLLOW and O_DIRECTORY")
        if root.exists() or root.is_symlink():
            metadata = root.lstat()
            if stat.S_ISLNK(metadata.st_mode):
                raise ValueError("output root must not be a symlink")
            if not stat.S_ISDIR(metadata.st_mode):
                raise ValueError("output root must be a directory")
        else:
            if not root.parent.is_dir():

View on GitHub (pinned to 8321021c54)