{"record":{"id":"b2ad29dbae5b1bfd","repo":"affaan-m/ECC","slug":"path-is-not-a-valid-directory-canonical-r","errorCode":null,"errorMessage":"Path is not a valid directory: {canonical!r}","messagePattern":"Path is not a valid directory: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"scripts/lib/ecc_dashboard_runtime.py","lineNumber":68,"sourceCode":"                'cwd': path,\n                'creationflags': creationflags,\n            },\n        )\n\n    if resolved_system_name == 'Darwin':\n        return (['open', '-a', 'Terminal', path], {})\n\n    return (\n        ['x-terminal-emulator', '-e', 'bash', '-lc', 'cd -- \"$1\"; exec bash', 'bash', path],\n        {},\n    )\n\n\ndef launch_terminal(path: str) -> None:\n    \"\"\"Open a terminal at the given path after validating the target directory.\"\"\"\n    canonical = os.path.realpath(path)\n    if not os.path.isdir(canonical):\n        raise ValueError(f\"Path is not a valid directory: {canonical!r}\")\n    argv, kwargs = build_terminal_launch(canonical)\n    subprocess.Popen(argv, **kwargs)  # noqa: S603 - list argv, no shell=True, path validated above\n","sourceCodeStart":50,"sourceCodeEnd":71,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/lib/ecc_dashboard_runtime.py#L50-L71","documentation":"Raised by launch_terminal in scripts/lib/ecc_dashboard_runtime.py when the requested path fails the os.path.isdir check after canonicalization via os.path.realpath. The function refuses to spawn a terminal subprocess pointing at a nonexistent or non-directory target, because the subsequent build_terminal_launch/Popen call assumes a valid working directory. It is a defensive pre-flight validation before process launch.","triggerScenarios":"Calling launch_terminal (directly or via open_terminal) with a path that does not exist, points at a regular file, or is a dangling symlink so realpath resolves to a non-directory.","commonSituations":"Dashboard passes a stale workspace directory that was deleted or renamed while the dashboard ran; user config points the terminal opener at a file instead of a directory; symlink targets removed on a mounted volume.","solutions":["Verify the path exists and is a directory before calling launch_terminal (os.path.isdir(os.path.realpath(path))).","Fix the dashboard/config value that supplied the wrong path (stale workspace, typo, file instead of directory).","Create the missing directory if it is expected to exist (os.makedirs(path, exist_ok=True)).","Handle the ValueError in open_terminal and surface a friendly message or fall back to the default working directory."],"exampleFix":"// before\nlaunch_terminal(workspace_path)  # may be stale\n// after\nif os.path.isdir(os.path.realpath(workspace_path)):\n    launch_terminal(workspace_path)\nelse:\n    print(f\"workspace not found: {workspace_path}\")","handlingStrategy":"validation","validationCode":"import os\nif not os.path.isdir(os.path.realpath(path)):\n    raise FileNotFoundError(f\"not a directory: {path}\")","typeGuard":"def is_valid_directory(path: str) -> bool:\n    return os.path.isdir(os.path.realpath(path))","tryCatchPattern":"try:\n    launch_terminal(path)\nexcept ValueError as e:\n    print(f\"cannot open terminal: {e}\")","preventionTips":["Check os.path.isdir on the realpath before launching","Keep workspace paths in config freshly validated at startup","Prefer directories over files when configuring terminal openers","Handle deleted/renamed workspaces by refreshing the dashboard state"],"tags":["python","filesystem","validation","terminal"],"backgroundTag":"path-is-not-a-directory","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"}