{"record":{"id":"a26cb8aa9838a998","repo":"affaan-m/ECC","slug":"reference-style-evidence-times-must-be-finite-and-within","errorCode":null,"errorMessage":"reference style evidence times must be finite and within duration","messagePattern":"reference style evidence times must be finite and within duration","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"skills/taste-application/scripts/tasteforge/workflow.py","lineNumber":164,"sourceCode":"    duration = cast(float, duration)\n    if float(duration) <= 0:\n        raise ValueError(\"reference probe duration must be finite and positive\")\n    for field in (\"sample_times\", \"scene_changes\"):\n        values = measured.get(field, [])\n        if not isinstance(values, list) or any(\n            not _finite_real(value) or float(value) < 0 or float(value) > float(duration)\n            for value in values\n        ):\n            raise ValueError(f\"reference probe {field} must contain finite in-duration times\")\n    samples = measured.get(\"style_samples\", [])\n    if not isinstance(samples, list) or any(\n        not isinstance(sample, dict)\n        or not _finite_real(sample.get(\"time\"))\n        or float(cast(float, sample[\"time\"])) < 0\n        or float(cast(float, sample[\"time\"])) > float(duration)\n        for sample in samples\n    ):\n        raise ValueError(\"reference style evidence times must be finite and within duration\")\n    return float(duration)\n\n\nclass _SafeOutput:\n    \"\"\"Descriptor-bound output tree with no-follow traversal and atomic writes.\"\"\"\n\n    def __init__(self, root: Path) -> None:\n        self._root_fd = -1\n        if not hasattr(os, \"O_NOFOLLOW\") or not hasattr(os, \"O_DIRECTORY\"):\n            raise RuntimeError(\"secure output requires O_NOFOLLOW and O_DIRECTORY\")\n        if root.exists() or root.is_symlink():\n            metadata = root.lstat()\n            if stat.S_ISLNK(metadata.st_mode):\n                raise ValueError(\"output root must not be a symlink\")\n            if not stat.S_ISDIR(metadata.st_mode):\n                raise ValueError(\"output root must be a directory\")\n        else:\n            if not root.parent.is_dir():","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/skills/taste-application/scripts/tasteforge/workflow.py#L146-L182","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure every style sample is a dict with a numeric finite 'time' key inside [0, duration]","Clamp sample times to the duration or regenerate samples from the actual probe clip","Fix the exporter that produces style_samples to emit {'time': float} entries","Pre-validate with a loop asserting isinstance(s, dict) and math.isfinite(s.get('time', float('nan')))"],"exampleFix":"# before\nmeasured['style_samples'] = [{'time': '2.5s'}, {'at': 7.0}]\n\n# after\nmeasured['style_samples'] = [{'time': 2.5}, {'time': 7.0}]\nrun_workflow(measured)","handlingStrategy":"validation","validationCode":"import math\ndef validate_style_samples(measured):\n    dur = float(measured['duration'])\n    return all(isinstance(s, dict)\n               and isinstance(s.get('time'), (int, float))\n               and not isinstance(s.get('time'), bool)\n               and math.isfinite(s['time'])\n               and 0 <= float(s['time']) <= dur\n               for s in measured.get('style_samples', []))","typeGuard":"def is_style_sample(s) -> bool:\n    t = s.get('time') if isinstance(s, dict) else None\n    return (isinstance(t, (int, float)) and not isinstance(t, bool)\n            and math.isfinite(t))","tryCatchPattern":"try:\n    run_workflow(measured)\nexcept ValueError as e:\n    if 'style evidence times' in str(e):\n        print('style_samples must be [{\"time\": <number in [0, duration>]}]')\n    else:\n        raise","preventionTips":["Standardize on a {'time': float} sample schema in all exporters","Clamp sample times to [0, duration] when regenerating samples from a trimmed clip","Never use timestamp strings ('2.5s'); store numeric seconds","Validate the whole measured dict with jsonschema before run_workflow"],"tags":["validation","python","schema"],"backgroundTag":"schema-validation-failed","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}