{"record":{"id":"a477ac10f7c2c8f9","repo":"affaan-m/ECC","slug":"filenotfounderror-source","errorCode":null,"errorMessage":"FileNotFoundError(source)","messagePattern":"FileNotFoundError\\(source\\)","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"skills/taste-application/scripts/tasteforge/media/glitch.py","lineNumber":118,"sourceCode":"def 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\",\n                str(duration),\n                \"-i\",\n                str(source),\n                \"-f\",","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/skills/taste-application/scripts/tasteforge/media/glitch.py#L100-L136","documentation":"render() checks Path(source).is_file() before spawning ffmpeg and raises FileNotFoundError(source) if the source path does not exist or is not a regular file. It fails fast instead of letting ffmpeg produce a confusing decoder failure.","triggerScenarios":"Passing a non-existent path to render(); the source being a directory or special device; a relative path that resolves differently from the working directory; upstream pipeline failing to produce the source before render runs.","commonSituations":"Wrong working directory when running a script; path built from unvalidated user input; source deleted between download and render; symlink to a missing target.","solutions":["Verify the path exists: os.path.isfile(source) before calling render","Print/resolve the absolute path (Path(source).resolve()) to spot wrong working-directory assumptions","Fix the upstream step that should have produced the source file","Check for typos or extension mismatches in the filename"],"exampleFix":"// before\nrender('vid.mp4', 0, out)  # file actually at ./media/vid.mp4\n// after\nsrc = Path('media/vid.mp4')\nassert src.is_file(), f'missing source: {src.resolve()}'\nrender(src, 0, out)","handlingStrategy":"validation","validationCode":"from pathlib import Path\nsrc_path = Path(source)\nif not src_path.is_file():\n    raise FileNotFoundError(f'source missing: {src_path.resolve()}')","typeGuard":null,"tryCatchPattern":"try:\n    render(source, 0, out)\nexcept FileNotFoundError as e:\n    print(f'source not found: {e}; cwd={os.getcwd()}')","preventionTips":["Resolve to absolute paths (Path(...).resolve()) when building source paths","Validate the file exists before invoking the pipeline","Check working-directory assumptions in scripts and cron jobs","Verify symlinks point to existing targets"],"tags":["filesystem","validation","media"],"backgroundTag":"file-not-found","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"}