{"record":{"id":"acbb4a1522dda373","repo":"zed-industries/zed","slug":"input-path-is-not-a-directory","errorCode":null,"errorMessage":"{input_path} is not a directory.","messagePattern":"(.+?) is not a directory\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/agent/src/tools/list_directory_tool.rs","lineNumber":131,"sourceCode":"        input_path: &str,\n        cx: &App,\n    ) -> Result<String> {\n        let worktree = project\n            .read(cx)\n            .worktree_for_id(project_path.worktree_id, cx)\n            .with_context(|| format!(\"{input_path} is not in a known worktree\"))?;\n\n        let global_settings = WorktreeSettings::get_global(cx);\n        let worktree_settings = WorktreeSettings::get(Some(project_path.into()), cx);\n        let worktree_snapshot = worktree.read(cx).snapshot();\n        let worktree_root_name = worktree.read(cx).root_name();\n\n        let Some(entry) = worktree_snapshot.entry_for_path(&project_path.path) else {\n            return Err(anyhow!(\"Path not found: {}\", input_path));\n        };\n\n        if !entry.is_dir() {\n            return Err(anyhow!(\"{input_path} is not a directory.\"));\n        }\n\n        let mut folders = Vec::new();\n        let mut files = Vec::new();\n\n        for entry in worktree_snapshot.child_entries(&project_path.path) {\n            // Skip private and excluded files and directories\n            if global_settings.is_path_private(&entry.path)\n                || global_settings.is_path_excluded(&entry.path)\n            {\n                continue;\n            }\n\n            let project_path: ProjectPath = (worktree_snapshot.id(), entry.path.clone()).into();\n            if worktree_settings.is_path_excluded(&project_path.path)\n                || worktree_settings.is_path_private(&project_path.path)\n            {\n                continue;","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/zed-industries/zed/blob/bc538def4545534201bbfcac4e95ac34ea6501b6/crates/agent/src/tools/list_directory_tool.rs#L113-L149","documentation":"The path exists in the worktree snapshot but is a file, not a directory: `entry.is_dir()` is false. The list-directory tool only enumerates directories, so the call fails with this message naming the input path. Nothing is listed and no filesystem access happens beyond the lookup.","triggerScenarios":"Passing a file path (e.g. `Cargo.toml`, `src/main.rs`) to the list-directory tool instead of a directory.","commonSituations":"The model confusing the list-directory and read-file tools; paths whose final component is a file (`src/lib.rs` instead of `src`); trailing-component mistakes after path manipulation.","solutions":["Pass the parent directory instead: `src/main.rs` → `src`.","Use the read-file tool when the target is a file.","Strip trailing file components from model-provided paths before invoking the tool."],"exampleFix":"# before\nlist_directory(\"Cargo.toml\")   # '<input> is not a directory.'\n\n# after\nlist_directory(\".\")            # or: read_file(\"Cargo.toml\")","handlingStrategy":"validation","validationCode":"let Some(entry) = worktree_snapshot.entry_for_path(&project_path.path) else {\n    anyhow::bail!(\"path not found: {input_path}\");\n};\nif !entry.is_dir() {\n    anyhow::bail!(\"{input_path} is a file — pass its parent directory\");\n}","typeGuard":"fn is_directory_in_worktree(\n    snapshot: &WorktreeSnapshot,\n    project_path: &ProjectPath,\n) -> bool {\n    snapshot\n        .entry_for_path(&project_path.path)\n        .map(|entry| entry.is_dir())\n        .unwrap_or(false)\n}","tryCatchPattern":null,"preventionTips":["Route file reads to the read-file tool; list only directories.","Trim trailing file components from model-provided paths before invoking list-directory.","State input expectations (directory, not file) clearly in the tool description."],"tags":["filesystem","tooling","path","validation"],"backgroundTag":null,"analyzedSha":"bc538def4545534201bbfcac4e95ac34ea6501b6","analyzedAt":"2026-08-16T07:30:46.435Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}