{"record":{"id":"56b91247e1986df3","repo":"affaan-m/ECC","slug":"reference-source-must-be-a-regular-file","errorCode":null,"errorMessage":"reference source must be a regular file","messagePattern":"reference source must be a regular file","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"skills/taste-application/scripts/tasteforge/workflow.py","lineNumber":67,"sourceCode":"    total = 0\n    while True:\n        chunk = os.read(descriptor, 1024 * 1024)\n        if not chunk:\n            break\n        total += len(chunk)\n        digest.update(chunk)\n    return total, digest.hexdigest()\n\n\ndef _stable_probe(path: Path, probe: Probe) -> tuple[dict[str, Any], int, str]:\n    \"\"\"Probe a private snapshot while binding the digest to one stable source object.\"\"\"\n    if not hasattr(os, \"O_NOFOLLOW\"):\n        raise ValueError(\"stable source probing requires O_NOFOLLOW\")\n    descriptor = os.open(path, os.O_RDONLY | os.O_NOFOLLOW)\n    try:\n        before = os.fstat(descriptor)\n        if not stat.S_ISREG(before.st_mode):\n            raise ValueError(\"reference source must be a regular file\")\n        with tempfile.TemporaryDirectory(prefix=\"tasteforge-source-\") as temporary:\n            snapshot = Path(temporary) / f\"source{path.suffix}\"\n            snapshot_fd = os.open(\n                snapshot, os.O_WRONLY | os.O_CREAT | os.O_EXCL | os.O_NOFOLLOW, 0o600\n            )\n            try:\n                os.lseek(descriptor, 0, os.SEEK_SET)\n                digest = hashlib.sha256()\n                total = 0\n                while True:\n                    chunk = os.read(descriptor, 1024 * 1024)\n                    if not chunk:\n                        break\n                    total += len(chunk)\n                    digest.update(chunk)\n                    view = memoryview(chunk)\n                    while view:\n                        written = os.write(snapshot_fd, view)","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/skills/taste-application/scripts/tasteforge/workflow.py#L49-L85","documentation":"_stable_probe opens the source path with O_NOFOLLOW and then fstats the resulting descriptor. If the object is not a regular file (e.g. a directory, FIFO, device node, or socket), the function raises this ValueError because hashing and snapshotting only make sense for regular files. It also guards against exotic inode types that would make the 'stable source object' guarantee meaningless.","triggerScenarios":"Passing a directory, named pipe (mkfifo), /dev device node, or socket as the source path to _stable_probe/run_workflow instead of a regular file.","commonSituations":"Typo/config pointing at a directory instead of the file (e.g. passing 'src/' instead of 'src/main.py'), redirecting the source path at a log FIFO, or a bind-mounted device file.","solutions":["Point the source path at a regular file (`stat.S_ISREG(os.stat(path).st_mode)` true).","If you meant a directory, supply the specific file inside it.","Check the path is not a FIFO/socket/device (`ls -l` shows p/s/b in the type column); replace it with a real file."],"exampleFix":"// before\npath = Path(\"src/engine\")  # a directory\nrun_workflow(path, probe)\n\n// after\npath = Path(\"src/engine/workflow.py\")\nimport stat\nassert stat.S_ISREG(path.stat().st_mode)\nrun_workflow(path, probe)","handlingStrategy":"validation","validationCode":"import os, stat\ndef is_regular_file(path):\n    st = os.stat(path, follow_symlinks=False)\n    return stat.S_ISREG(st.st_mode)\n\nif not is_regular_file(source_path):\n    raise ValueError(f\"{source_path} is not a regular file\")","typeGuard":"import stat, os\ndef is_regular_file_path(path) -> bool:\n    try:\n        return stat.S_ISREG(os.stat(path, follow_symlinks=False).st_mode)\n    except OSError:\n        return False","tryCatchPattern":null,"preventionTips":["Validate the source path is S_ISREG before calling the workflow.","Avoid pointing config at directories or FIFOs; keep explicit file paths.","Resolve the path (no symlinks) before validation."],"tags":["filesystem","validation","argument-type"],"backgroundTag":"incompatible-source-type","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"}