{"record":{"id":"ae4959aceca03038","repo":"zed-industries/zed","slug":"absolute-path-not-allowed-path","errorCode":null,"errorMessage":"absolute path not allowed: {path:?}","messagePattern":"absolute path not allowed: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/path/src/rel_path.rs","lineNumber":77,"sourceCode":"    pub fn new<'a>(path: &'a Path, path_style: PathStyle) -> Result<Cow<'a, Self>> {\n        let mut path = path.to_str().context(\"non utf-8 path\")?;\n\n        let (prefixes, suffixes): (&[_], &[_]) = match path_style {\n            PathStyle::Unix => (&[\"./\"], &['/']),\n            PathStyle::Windows => (&[\"./\", \".\\\\\"], &['/', '\\\\']),\n        };\n\n        while prefixes.iter().any(|prefix| path.starts_with(prefix)) {\n            path = &path[prefixes[0].len()..];\n        }\n        while let Some(prefix) = path.strip_suffix(suffixes)\n            && !prefix.is_empty()\n        {\n            path = prefix;\n        }\n\n        if is_absolute(&path, path_style) {\n            return Err(anyhow!(\"absolute path not allowed: {path:?}\"));\n        }\n\n        let mut string = Cow::Borrowed(path);\n        if path_style == PathStyle::Windows && path.contains('\\\\') {\n            string = Cow::Owned(string.as_ref().replace('\\\\', \"/\"))\n        }\n\n        let mut result = match string {\n            Cow::Borrowed(string) => Cow::Borrowed(Self::from_str(string)),\n            Cow::Owned(string) => Cow::Owned(RelPathBuf(string)),\n        };\n\n        if result\n            .components()\n            .any(|component| component == \"\" || component == \".\" || component == \"..\")\n        {\n            let mut normalized = RelPathBuf::new();\n            for component in result.components() {","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/path/src/rel_path.rs#L59-L95","documentation":"RelPath::new rejected the input because, after stripping leading './' prefixes and trailing separators, the remaining string still looks absolute (e.g. starts with '/' or a Windows drive prefix). RelPath's invariant is that it names something under a worktree root, so absolute paths are forbidden.","triggerScenarios":"Thrown at crates/path/src/rel_path.rs:77 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Strip the absolute prefix before constructing the RelPath — usually by making the path relative to the worktree root","Check PathStyle handling on Windows, where both '/' and '\\' roots and drive letters must be removed","Validate persisted relative paths (settings, databases) for absolute entries that may have leaked in"],"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-14T00:17:10.932Z"}