{"record":{"id":"184feb335270e8c0","repo":"affaan-m/ECC","slug":"path-does-not-exist-path","errorCode":null,"errorMessage":"Path does not exist: {path}","messagePattern":"Path does not exist: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"skills/continuous-learning-v2/scripts/instinct-cli.py","lineNumber":171,"sourceCode":"    \"\"\"\n    path = Path(path_str).expanduser().resolve()\n\n    # Block paths that escape into system directories\n    # We block specific system paths but allow temp dirs (/var/folders on macOS)\n    blocked_prefixes = [\n        \"/etc\", \"/usr\", \"/bin\", \"/sbin\", \"/proc\", \"/sys\",\n        \"/var/log\", \"/var/run\", \"/var/lib\", \"/var/spool\",\n        # macOS resolves /etc → /private/etc\n        \"/private/etc\",\n        \"/private/var/log\", \"/private/var/run\", \"/private/var/db\",\n    ]\n    path_s = str(path)\n    for prefix in blocked_prefixes:\n        if path_s.startswith(prefix + \"/\") or path_s == prefix:\n            raise ValueError(f\"Path '{path}' targets a system directory\")\n\n    if must_exist and not path.exists():\n        raise ValueError(f\"Path does not exist: {path}\")\n\n    return path\n\n\ndef _validate_instinct_id(instinct_id: str) -> bool:\n    \"\"\"Validate instinct IDs before using them in filenames.\"\"\"\n    if not instinct_id or len(instinct_id) > 128:\n        return False\n    if \"/\" in instinct_id or \"\\\\\" in instinct_id:\n        return False\n    if \"..\" in instinct_id:\n        return False\n    if instinct_id.startswith(\".\"):\n        return False\n    return bool(re.match(r\"^[A-Za-z0-9][A-Za-z0-9._-]*$\", instinct_id))\n\n\ndef _validate_import_url(source: str) -> str:","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/skills/continuous-learning-v2/scripts/instinct-cli.py#L153-L189","documentation":"Raised by _validate_file_path when must_exist is true and pathlib.Path.exists() returns False for the supplied path. The import/export commands require the target file to already be present before reading or validating it. It is a plain existence check that runs after the system-prefix blocklist.","triggerScenarios":"Calling cmd_import/cmd_export with a file path that does not exist on disk while must_exist is enabled — e.g. a misspelled filename, wrong working directory, or a file deleted between planning and running the command.","commonSituations":"Running the CLI from a different cwd than the script author assumed so a relative path no longer resolves; typo in the path; file removed by a cleanup job or not yet generated by a prior step.","solutions":["Verify the file exists (Path(path).exists()) and correct any typo in the path.","Run the command from the intended working directory or use an absolute path.","Create the file first (e.g. export instincts before a later import step).","Wrap the command and catch the ValueError to print a friendly 'file not found' message."],"exampleFix":"# before\nsubprocess.run([\"python\", \"instinct-cli.py\", \"import\", \"--file\", \"instincts.yaml\"])  # wrong cwd\n# after\nfrom pathlib import Path\nsrc = Path.home() / \".config/ecc-instincts/instincts.yaml\"\nassert src.exists(), f\"missing input: {src}\"\nsubprocess.run([\"python\", \"instinct-cli.py\", \"import\", \"--file\", str(src)])","handlingStrategy":"validation","validationCode":"from pathlib import Path\np = Path(path)\nif not p.exists():\n    raise FileNotFoundError(p)","typeGuard":null,"tryCatchPattern":"try:\n    cli_import(file=path)\nexcept ValueError as e:\n    if \"does not exist\" in str(e):\n        print(f\"input file missing: {path}\")","preventionTips":["Run the CLI from the intended working directory or use absolute paths","Check Path(path).exists() before invoking","Generate prerequisite files before running import/export steps","Avoid typos by tab-completing paths or resolving from a config"],"tags":["python","filesystem","cli","validation"],"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"}