{"record":{"id":"e50f29c320fd4182","repo":"affaan-m/ECC","slug":"clip-i-path-has-non-positive-duration-dur-r-timeline","errorCode":null,"errorMessage":"clip {i} ({path}) has non-positive duration {dur!r}","messagePattern":"clip (.+?) \\((.+?)\\) has non-positive duration (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"skills/taste-distillation/scripts/taste/timeline.py","lineNumber":221,"sourceCode":"# ---------------------------------------------------------------------------\n\n\ndef _normalise(clips: Iterable[dict], fps: float | Fraction) -> list[dict]:\n    \"\"\"Validate clips and pre-compute integer frame counts and offsets.\n\n    Returns dicts with ``path``, ``name``, ``frames`` (int, >= 1) and\n    ``offset_frames`` (int). Working in frames from here down is what makes the\n    sequence duration exactly the sum of the clip durations.\n    \"\"\"\n    out: list[dict] = []\n    offset = 0\n    for i, c in enumerate(clips):\n        path = str(c.get(\"path\") or \"\")\n        if not path:\n            raise ValueError(f\"clip {i} has no 'path'\")\n        dur = float(c.get(\"duration\") or 0.0)\n        if dur <= 0:\n            raise ValueError(f\"clip {i} ({path}) has non-positive duration {dur!r}\")\n        frames = max(1, seconds_to_frames(dur, fps))  # never emit a zero-length event\n        name = str(c.get(\"name\") or Path(path).stem)\n        out.append(\n            {\n                \"path\": path,\n                \"name\": name,\n                \"frames\": frames,\n                \"offset_frames\": offset,\n                \"seconds\": dur,\n            }\n        )\n        offset += frames\n    if not out:\n        raise ValueError(\"no clips to write - a timeline needs at least one event\")\n    return out\n\n\ndef _file_uri(path: str) -> str:","sourceCodeStart":203,"sourceCodeEnd":239,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/skills/taste-distillation/scripts/taste/timeline.py#L203-L239","documentation":"_normalise() rejects clips whose duration is missing, zero, or negative (float(c.get('duration') or 0.0) then dur <= 0). A timeline event with no positive length is meaningless, so the builder raises with the clip index, path, and offending duration.","triggerScenarios":"Calling build_fcpxml/build_edl with a clip {\"path\": p} lacking 'duration' (None -> 0.0), or duration=0, or a negative value from a bad cut calculation.","commonSituations":"Duration not yet measured when the manifest was generated; end-start computing to 0 for zero-length segments; None passed where seconds were expected.","solutions":["Set a positive 'duration' (seconds) on every clip dict","Filter or repair zero-duration clips before building","Check upstream in/out-point math (end - start) for degenerate ranges","Measure clip durations with ffprobe and fill them into the manifest"],"exampleFix":"// before\nclips = [{\"path\": \"a.mp4\", \"duration\": 0}]\n// after\nclips = [{\"path\": \"a.mp4\", \"duration\": max(0.04, end - start)}]","handlingStrategy":"validation","validationCode":"bad = [i for i, c in enumerate(clips) if float(c.get('duration') or 0) <= 0]\nif bad:\n    raise ValueError(f'clips with non-positive duration: {bad}')","typeGuard":"def has_positive_duration(c: dict) -> bool:\n    try:\n        return float(c.get('duration') or 0) > 0\n    except (TypeError, ValueError):\n        return False","tryCatchPattern":"try:\n    build_edl(clips, fps=24)\nexcept ValueError as e:\n    if 'non-positive duration' in str(e):\n        logger.error('bad clip durations: %s', e)\n        raise","preventionTips":["Compute durations as max(min_duration, end - start)","Measure clip durations with ffprobe before manifest generation","Reject degenerate cuts (start >= end) upstream"],"tags":["value-error","validation","duration","timeline"],"backgroundTag":"value-out-of-range","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"}