{"record":{"id":"cadabe8209204592","repo":"affaan-m/ECC","slug":"seed-must-be-a-nonnegative-integer","errorCode":null,"errorMessage":"Seed must be a nonnegative integer","messagePattern":"Seed must be a nonnegative integer","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"skills/taste-application/scripts/tasteforge/media/glitch.py","lineNumber":120,"sourceCode":"    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\",\n                str(duration),\n                \"-i\",\n                str(source),\n                \"-f\",\n                \"rawvideo\",\n                \"-pix_fmt\",","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/skills/taste-application/scripts/tasteforge/media/glitch.py#L102-L138","documentation":"render() validates the random seed used by the deterministic glitch effects. It must be a genuine int (bool is explicitly rejected) and non-negative; otherwise it raises ValueError('Seed must be a nonnegative integer').","triggerScenarios":"Passing seed=True/False (bools are ints in Python but rejected explicitly); passing a negative int like -1; passing a float such as 1.5 or a numeric string like '42'.","commonSituations":"Feeding seed from a config where it was parsed as float; using a hash that can be negative (e.g. Python's hash()); accidentally passing a boolean flag as the seed parameter positionally.","solutions":["Pass a plain non-negative int, e.g. seed=42","Convert negative hashes with abs() or mask: seed & 0xFFFFFFFF","Coerce validated input: seed = int(value); assert seed >= 0","Reorder arguments if a bool was passed positionally into the seed slot"],"exampleFix":"// before\nrender(src, 0, out, seed=random.getrandbits(32) - 2**31)  # can be negative\n// after\nrender(src, 0, out, seed=random.getrandbits(32))  # always non-negative","handlingStrategy":"type-guard","validationCode":"if isinstance(seed, bool) or not isinstance(seed, int) or seed < 0:\n    raise ValueError('seed must be a nonnegative int')","typeGuard":"def is_valid_seed(v) -> bool:\n    return isinstance(v, int) and not isinstance(v, bool) and v >= 0","tryCatchPattern":"try:\n    render(src, 0, out, seed=seed)\nexcept ValueError as e:\n    if 'Seed must be' in str(e):\n        seed = abs(int(seed))\n        render(src, 0, out, seed=seed)","preventionTips":["Use random.getrandbits(32) or secrets.randbits for seed generation","Never pass bools as seeds; they are explicitly rejected","Coerce config values with int() and range-check before calling","Store seeds as unsigned integers in configs"],"tags":["validation","seed","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"}