{"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":"validation","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/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/agent/src/tools/tool_permissions.rs#L382-L418","documentation":"Emitted by resolve_project_path, the central path-safety guard for agent file tools, when project.find_project_path returns None for the given input path. The path does not map to any entry in the project's worktree snapshots, so it is outside project boundaries and the caller must refuse to operate on it. The offending input is the path argument passed to resolve_project_path.","triggerScenarios":"Thrown at crates/agent/src/tools/tool_permissions.rs:400 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a path relative to one of the open worktree roots","Ensure the file or directory exists inside an open worktree before referencing it","Open the containing directory as a worktree in the project first"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}