{"record":{"id":"67a94f884a4aa967","repo":"zed-industries/zed","slug":"is-not-a-directory","errorCode":null,"errorMessage":"{} is not a directory.","messagePattern":"(.+?) is not a directory\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/agent/src/tools/list_directory_tool.rs","lineNumber":311,"sourceCode":"                    anyhow::bail!(\n                        \"Cannot list directory because its path matches the user's worktree `file_scan_exclusions` setting: {}\",\n                        input.path\n                    );\n                }\n\n                if worktree_settings.is_path_private(&project_path.path) {\n                    anyhow::bail!(\n                        \"Cannot list directory because its path matches the user's worktree `private_paths` setting: {}\",\n                        input.path\n                    );\n                }\n\n                let worktree_snapshot = worktree.read(cx).snapshot();\n                let Some(entry) = worktree_snapshot.entry_for_path(&project_path.path) else {\n                    anyhow::bail!(\"Path not found: {}\", input.path);\n                };\n                if !entry.is_dir() {\n                    anyhow::bail!(\"{} is not a directory.\", input.path);\n                }\n\n                anyhow::Ok(())\n            }).map_err(|e| e.to_string())?;\n\n            if let Some(canonical_target) = &symlink_canonical_target {\n                let authorize = cx.update(|cx| {\n                    authorize_symlink_access(\n                        Self::NAME,\n                        &input.path,\n                        canonical_target,\n                        &event_stream,\n                        cx,\n                    )\n                });\n                authorize.await.map_err(|e| e.to_string())?;\n            }\n","sourceCodeStart":293,"sourceCodeEnd":329,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/agent/src/tools/list_directory_tool.rs#L293-L329","documentation":"`list_directory` looks the path up in the worktree snapshot and requires the entry to be a directory (`entry.is_dir()`). A snapshot entry that is a regular file (or any non-directory) makes the tool bail with `{path} is not a directory.` The check happens after existence, so the path exists but has the wrong type.","triggerScenarios":"Calling `list_directory` on a file path — e.g. `list_directory(\"src/main.rs\")` — or on a symlink whose snapshot entry is a file.","commonSituations":"The model confuses a file for a directory (common for extension-less files like `LICENSE`, `Makefile`, `Dockerfile`), or a path swapped from directory to file during a refactor.","solutions":["Use the `read_file` tool for file paths — it is the counterpart that requires a non-directory.","List the parent directory to discover the real children and pick a directory entry.","If the path should be a directory, check whether it was replaced by a file on disk."],"exampleFix":"// tool call before\n{ \"path\": \"src/main.rs\" }        // list_directory on a file -> error\n// tool call after\n{ \"path\": \"src\" }                  // list the parent directory\n// or switch tools\nread_file({ \"path\": \"src/main.rs\" })","handlingStrategy":"type-guard","validationCode":"if let Some(entry) = worktree.read(cx).snapshot().entry_for_path(&project_path.path) {\n    if !entry.is_dir() {\n        // route to read_file instead of list_directory\n    }\n}","typeGuard":"fn is_listable_dir(snapshot: &WorktreeSnapshot, path: &ProjectPath) -> bool {\n    snapshot.entry_for_path(&path.path).is_some_and(|entry| entry.is_dir())\n}","tryCatchPattern":"match list_directory(path).await {\n    Err(e) if e.to_string().contains(\"is not a directory\") => read_file(path).await,\n    rest => rest,\n}","preventionTips":["Branch tool choice on `entry.is_dir()` before calling.","Treat extension-less names (LICENSE, Dockerfile) as likely files when planning calls.","When a generic 'explore path' intent is needed, check the entry kind first."],"tags":["rust","zed","agent","list-directory","not-a-directory","wrong-tool"],"backgroundTag":"not-a-directory","analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}