{"record":{"id":"3aca45a7e6e3688d","repo":"zed-industries/zed","slug":"cannot-list-directory-because-its-path-matches-the-3aca45","errorCode":null,"errorMessage":"Cannot list directory because its path matches the user's worktree `private_paths` setting: {}","messagePattern":"Cannot list directory because its path matches the user's worktree `private_paths` setting: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/agent/src/tools/list_directory_tool.rs","lineNumber":300,"sourceCode":"                }\n\n                if global_settings.is_path_private(&project_path.path) {\n                    anyhow::bail!(\n                        \"Cannot list directory because its path matches the user's global `private_files` setting: {}\",\n                        input.path\n                    );\n                }\n\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| {","sourceCodeStart":282,"sourceCodeEnd":318,"githubUrl":"https://github.com/zed-industries/zed/blob/bc538def4545534201bbfcac4e95ac34ea6501b6/crates/agent/src/tools/list_directory_tool.rs#L282-L318","documentation":"The final settings gate in list_directory: the directory matches the worktree-level private paths setting (`private_paths`, enforced through is_path_private on worktree-scoped WorktreeSettings). Like global private_files it is a security boundary, but scoped to the repository, letting a repo declare its own sensitive locations that the agent must never enumerate.","triggerScenarios":"list_directory where the global checks pass but the worktree's `private_paths` globs match the requested path.","commonSituations":"A repository checks in .zed/settings.json marking local credential or key directories private; the agent is asked to explore them.","solutions":["Respect the policy — do not expose the private path to the agent","Narrow the worktree `private_paths` glob in .zed/settings.json if the match is accidental","Move the content you actually need out of the private-matching path"],"exampleFix":"// before — <repo>/.zed/settings.json\n\"private_paths\": [\"local/**\"]\n\n// after — only the credentials dir is private\n\"private_paths\": [\"local/creds/**\"]","handlingStrategy":"validation","validationCode":"let private = project.read_with(cx, |_, cx| {\n    WorktreeSettings::get(Some((&project_path).into()), cx)\n        .is_path_private(&project_path.path)\n});\nif private {\n    // repository-declared private path; refuse before calling the tool\n}","typeGuard":null,"tryCatchPattern":"Match `private_paths` in the message and stop; report that the repository's own settings mark the path private.","preventionTips":["Scope repo-level private_paths tightly to credential material only","Treat a private_paths error as a security signal, never as a bug to work around"],"tags":["agent","list-directory","private-paths","worktree-settings","security"],"backgroundTag":null,"analyzedSha":"bc538def4545534201bbfcac4e95ac34ea6501b6","analyzedAt":"2026-08-16T07:30:46.435Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}