{"record":{"id":"39b3dca74726e2e8","repo":"affaan-m/ECC","slug":"start-must-be-finite-and-nonnegative","errorCode":null,"errorMessage":"Start must be finite and nonnegative","messagePattern":"Start must be finite and nonnegative","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"skills/taste-application/scripts/tasteforge/media/glitch.py","lineNumber":114,"sourceCode":"        raise RuntimeError(\"Decoder produced no frames\")\n    return n\n\n\ndef render(\n    source,\n    start,\n    duration,\n    output,\n    seed,\n    mode=\"drift\",\n    width=1920,\n    height=1080,\n    fps=30,\n    overwrite=False,\n):\n    geometry(width, height, fps, duration)\n    if not math.isfinite(start) or start < 0:\n        raise ValueError(\"Start must be finite and nonnegative\")\n    if mode not in (\"drift\", \"feedback\", \"pixelsort\", \"mosh\"):\n        raise ValueError(\"Unknown effect mode\")\n    if not Path(source).is_file():\n        raise FileNotFoundError(source)\n    if isinstance(seed, bool) or not isinstance(seed, int) or seed < 0:\n        raise ValueError(\"Seed must be a nonnegative integer\")\n    if Path(source).resolve() == Path(output).resolve():\n        raise ValueError(\"Output must differ from the original source media\")\n    with output_file(output, overwrite) as temporary:\n        dec = subprocess.Popen(\n            [\n                \"ffmpeg\",\n                \"-nostdin\",\n                \"-v\",\n                \"error\",\n                \"-ss\",\n                str(start),\n                \"-t\",","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/skills/taste-application/scripts/tasteforge/media/glitch.py#L96-L132","documentation":"render() validates its arguments before doing any work. The start timestamp must be a finite (not NaN/inf) and non-negative number of seconds. It raises ValueError('Start must be finite and nonnegative') otherwise, failing fast instead of producing a nonsensical ffmpeg seek command.","triggerScenarios":"Passing start=float('nan'), float('inf'), or a negative number to render(); passing a value parsed from unvalidated config/CLI input.","commonSituations":"Parsing timestamps from external data where NaN slipped in (e.g. float('nan') from a JSON config or empty field converted to float); subtracting timestamps and getting a negative offset; a computation like (end-start) returning -0.000001 due to floating point.","solutions":["Pass a plain non-negative float/int for start","Clamp or validate the value before calling: max(0.0, start)","Fix the upstream calculation that produces the timestamp (check for NaN from missing data)","If input is user/config supplied, parse and validate it as a finite number first"],"exampleFix":"// before\nstart = float(config.get('start'))  # NaN if missing\nrender(src, start, ...)\n// after\nstart = float(config.get('start', 0.0))\nif not math.isfinite(start) or start < 0: start = 0.0\nrender(src, start, ...)","handlingStrategy":"validation","validationCode":"import math\nif not isinstance(start, (int, float)) or not math.isfinite(start) or start < 0:\n    raise ValueError('start must be a finite nonnegative number')","typeGuard":"def is_valid_start(v) -> bool:\n    return isinstance(v, (int, float)) and not isinstance(v, bool) and math.isfinite(v) and v >= 0","tryCatchPattern":"try:\n    render(src, start, out)\nexcept ValueError as e:\n    if 'Start must be' in str(e):\n        start = 0.0\n        render(src, start, out)","preventionTips":["Clamp user/config timestamps with max(0.0, value)","Check for NaN when values come from parsed external data","Type-annotate start as float and validate at the boundary","Beware floating-point subtraction producing tiny negative offsets"],"tags":["validation","argument","media"],"backgroundTag":"invalid-argument-value","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"}