{"record":{"id":"5a3fea6b43709c1a","repo":"zed-industries/zed","slug":"cannot-read-file-because-its-path-matches-the-glob-5a3fea","errorCode":null,"errorMessage":"Cannot read file because its path matches the global `private_files` setting: {}","messagePattern":"Cannot read file because its path matches the global `private_files` setting: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/agent/src/tools/read_file_tool.rs","lineNumber":312,"sourceCode":"                .read_with(cx, |project, cx| {\n                    project.absolute_path(&project_path, cx)\n                })\n                .ok_or_else(|| {\n                    anyhow!(\"Failed to convert {} to absolute path\", input.path)\n                }).map_err(tool_content_err)?;\n\n            // Check settings exclusions synchronously\n            project.read_with(cx, |_project, cx| {\n                let global_settings = WorktreeSettings::get_global(cx);\n                if global_settings.is_path_excluded(&project_path.path) {\n                    anyhow::bail!(\n                        \"Cannot read file because its path matches the global `file_scan_exclusions` setting: {}\",\n                        input.path\n                    );\n                }\n\n                if global_settings.is_path_private(&project_path.path) {\n                    anyhow::bail!(\n                        \"Cannot read file because its path matches the 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 read file because its path matches the 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 read file because its path matches the worktree `private_files` setting: {}\",\n                        input.path\n                    );","sourceCodeStart":294,"sourceCodeEnd":330,"githubUrl":"https://github.com/zed-industries/zed/blob/bc538def4545534201bbfcac4e95ac34ea6501b6/crates/agent/src/tools/read_file_tool.rs#L294-L330","documentation":"read_file rejects files matching the global `private_files` setting before touching the filesystem. This is a security control: private_files keeps secrets such as keys and .env files out of agent context entirely, and unlike file_scan_exclusions it should not be loosened to make a tool call succeed.","triggerScenarios":"read_file on a path matched by a global `private_files` glob (`.env*`, `**/*.pem`, `**/id_rsa*`). Checked after the global file_scan_exclusions gate and before worktree settings.","commonSituations":"The agent tries to read a secrets file while debugging config loading; defaults or user policy intentionally block it.","solutions":["Never route secrets through the agent — reference them by name and inject them via a secret manager at runtime","If the glob over-matches non-secret files, narrow `private_files` in global settings.json","Move non-secret files out of the private-matching path"],"exampleFix":"// before — global settings.json marks all of keys/ private\n\"private_files\": [\"keys/**\"]\n\n// after — only credential material is private\n\"private_files\": [\"keys/*.pem\", \"keys/*.env\"]","handlingStrategy":"validation","validationCode":"let private = project.read_with(cx, |_, cx| {\n    WorktreeSettings::get_global(cx).is_path_private(&project_path.path)\n});\nif private {\n    // secret material: never pass to read_file\n}","typeGuard":null,"tryCatchPattern":"On a private_files read error, stop and inform the user the file is secret by policy; do not retry, do not attempt alternate read paths.","preventionTips":["Store secrets outside the workspace or under private_files-covered paths so the agent can never read them","Reference secrets by name in agent sessions; inject values via a secret manager at runtime"],"tags":["agent","read-file","private-files","settings","security"],"backgroundTag":null,"analyzedSha":"bc538def4545534201bbfcac4e95ac34ea6501b6","analyzedAt":"2026-08-16T07:30:46.435Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}