{"record":{"id":"b74a3b1fb5905255","repo":"zed-industries/zed","slug":"path-not-found","errorCode":null,"errorMessage":"Path not found: {}","messagePattern":"Path not found: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/agent/src/tools/list_directory_tool.rs","lineNumber":308,"sourceCode":"\n                let worktree_settings = WorktreeSettings::get(Some((&project_path).into()), cx);\n                if worktree_settings.is_path_excluded(&project_path.path) {\n                    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                });","sourceCodeStart":290,"sourceCodeEnd":326,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/agent/src/tools/list_directory_tool.rs#L290-L326","documentation":"The `list_directory` tool resolves the input path against a project worktree and looks it up in that worktree's snapshot via `entry_for_path`. When the snapshot contains no entry for the path, the tool bails with `Path not found: {input.path}`. The snapshot reflects what the worktree's fs scan knows, so brand-new or unscanned directories can also miss.","triggerScenarios":"Calling `list_directory` on a deleted/renamed directory, a path with a typo, a path that lives in a different worktree than the one it was resolved to, or a directory created so recently the worktree scan has not recorded it yet.","commonSituations":"The agent guesses at a directory name that does not exist; the user renamed the folder mid-session; the path is outside every open worktree root; or a just-created build directory is not yet in the snapshot.","solutions":["List the parent directory first (`list_directory` on `.` or the parent) to see the actual entry names.","Verify the path is inside one of the project's open worktree roots and spelled exactly (case-sensitive on Linux).","For a freshly created directory, wait for the fs scan or trigger it by focusing the project panel, then retry.","Check the file actually exists on disk (`ls` the path) to rule out a stale snapshot."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Check the snapshot before invoking the tool:\nlet snapshot = worktree.read(cx).snapshot();\nif snapshot.entry_for_path(&project_path.path).is_none() {\n    // path unknown to the worktree (deleted, typo, other worktree) — don't call\n}","typeGuard":null,"tryCatchPattern":"match list_directory(path).await {\n    Err(e) if e.to_string().starts_with(\"Path not found\") => {\n        // list the parent directory to discover valid entries\n    }\n    rest => rest,\n}","preventionTips":["Resolve agent-visible paths from `worktree_snapshot.entry_for_path`, not from raw strings.","List parent directories first to validate names before diving deeper.","Re-check the snapshot after create/rename operations instead of assuming the entry exists."],"tags":["rust","zed","agent","list-directory","path-not-found","worktree-snapshot"],"backgroundTag":"file-not-found","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"}