affaan-m/ECC · error · ValueError
Seed must be a nonnegative integer
Error message
Seed must be a nonnegative integer
What it means
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').
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
Example fix
// before render(src, 0, out, seed=random.getrandbits(32) - 2**31) # can be negative // after render(src, 0, out, seed=random.getrandbits(32)) # always non-negative
Defensive patterns
Strategy: type-guard
Validate before calling
if isinstance(seed, bool) or not isinstance(seed, int) or seed < 0:
raise ValueError('seed must be a nonnegative int') Type guard
def is_valid_seed(v) -> bool:
return isinstance(v, int) and not isinstance(v, bool) and v >= 0 Try / catch
try:
render(src, 0, out, seed=seed)
except ValueError as e:
if 'Seed must be' in str(e):
seed = abs(int(seed))
render(src, 0, out, seed=seed) Prevention
- 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
When it happens
Trigger: 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'.
Common situations: 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.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- apply_local needs at least one media clip
- asset contains too few frames
- asset requires verified alpha
- candidate fps/duration/retime ambiguity
- Crop must contain four finite values
AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16).
Data as JSON: /api/errors/cadabe8209204592.
Report an issue: GitHub.
Appendix: source
Thrown at skills/taste-application/scripts/tasteforge/media/glitch.py:120
start,
duration,
output,
seed,
mode="drift",
width=1920,
height=1080,
fps=30,
overwrite=False,
):
geometry(width, height, fps, duration)
if not math.isfinite(start) or start < 0:
raise ValueError("Start must be finite and nonnegative")
if mode not in ("drift", "feedback", "pixelsort", "mosh"):
raise ValueError("Unknown effect mode")
if not Path(source).is_file():
raise FileNotFoundError(source)
if isinstance(seed, bool) or not isinstance(seed, int) or seed < 0:
raise ValueError("Seed must be a nonnegative integer")
if Path(source).resolve() == Path(output).resolve():
raise ValueError("Output must differ from the original source media")
with output_file(output, overwrite) as temporary:
dec = subprocess.Popen(
[
"ffmpeg",
"-nostdin",
"-v",
"error",
"-ss",
str(start),
"-t",
str(duration),
"-i",
str(source),
"-f",
"rawvideo",
"-pix_fmt",View on GitHub (pinned to 8321021c54)