{"record":{"id":"a793036f4a008403","repo":"zed-industries/zed","slug":"path-is-not-in-the-project","errorCode":null,"errorMessage":"Path {} is not in the project","messagePattern":"Path (.+?) is not in the project","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/agent/src/tools/tool_permissions.rs","lineNumber":400,"sourceCode":"/// # Returns\n///\n/// - `Ok(ResolvedProjectPath::Safe(project_path))` — the path resolves to a\n///   location within the project boundaries.\n/// - `Ok(ResolvedProjectPath::SymlinkEscape { .. })` — the path resolves\n///   through a symlink to a location outside the project. Agent tools should\n///   prompt the user before proceeding.\n/// - `Err(..)` — the path could not be found in the project or could not be\n///   verified. The error message is suitable for returning to the model.\npub fn resolve_project_path(\n    project: &Project,\n    path: impl AsRef<Path>,\n    canonical_worktree_roots: &[PathBuf],\n    cx: &App,\n) -> Result<ResolvedProjectPath> {\n    let path = path.as_ref();\n    let project_path = project\n        .find_project_path(path, cx)\n        .ok_or_else(|| anyhow!(\"Path {} is not in the project\", path.display()))?;\n\n    let worktree = project\n        .worktree_for_id(project_path.worktree_id, cx)\n        .ok_or_else(|| anyhow!(\"Could not resolve path {}\", path.display()))?;\n    let snapshot = worktree.read(cx);\n\n    // Fast path: if the entry exists in the snapshot and is not marked\n    // external, we know it's safe (the background scanner already verified).\n    if let Some(entry) = snapshot.entry_for_path(&project_path.path) {\n        if !entry.is_external {\n            return Ok(ResolvedProjectPath::Safe(project_path));\n        }\n\n        // Entry is external (set by the worktree scanner when a symlink's\n        // canonical target is outside the worktree root). Return the\n        // canonical path if the entry has one, otherwise fall through to\n        // filesystem-level canonicalization.\n        if let Some(canonical) = &entry.canonical_path {","sourceCodeStart":382,"sourceCodeEnd":418,"githubUrl":"https://github.com/zed-industries/zed/blob/bc538def4545534201bbfcac4e95ac34ea6501b6/crates/agent/src/tools/tool_permissions.rs#L382-L418","documentation":"resolve_project_path is the authorization gate every agent tool path passes through. It first maps the path with Project::find_project_path; None means the path is not under any open worktree, and this error (worded for the model) is returned so the tool refuses to touch paths outside the project.","triggerScenarios":"Any agent tool call whose path resolves outside every worktree: absolute paths under ~ or /etc, relative paths that escape the roots, or paths copied from a different project or machine.","commonSituations":"The agent proposes editing a config outside the workspace; the project root was moved or re-opened elsewhere; a stale absolute prefix survives in a saved prompt.","solutions":["Open the containing folder as an additional worktree (Add Folder to Project) and retry","Restrict the request to paths inside the current project","Fix stale absolute prefixes or wrong-relative paths in the request"],"exampleFix":"// before — path outside every worktree\nedit_file(path=\"/etc/app/config.toml\", ...)\n\n// after — the folder is added to the project first\nedit_file(path=\"/home/me/work/app/config.toml\", ...)","handlingStrategy":"validation","validationCode":"if project.find_project_path(&path, cx).is_none() {\n    // path is outside every worktree; reject before invoking the tool\n}","typeGuard":null,"tryCatchPattern":"Match 'is not in the project' in the tool error, then either add the containing folder as a worktree or re-scope the request to in-project paths.","preventionTips":["Open every folder the agent may need to touch as a worktree before starting the session","Prefer project-relative paths over absolute paths in agent requests"],"tags":["agent","tool-permissions","path","worktree","security"],"backgroundTag":null,"analyzedSha":"bc538def4545534201bbfcac4e95ac34ea6501b6","analyzedAt":"2026-08-16T07:30:46.435Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}