{"record":{"id":"584dfd0060baae1c","repo":"gitbutlerapp/gitbutler","slug":"projecthandle-payload-must-decode-to-an-absolute-f","errorCode":null,"errorMessage":"ProjectHandle payload must decode to an absolute filesystem path, got '{}'","messagePattern":"ProjectHandle payload must decode to an absolute filesystem path, got '(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-project-handle/src/project_handle.rs","lineNumber":112,"sourceCode":"}\n\nimpl TryFrom<ProjectHandle> for PathBuf {\n    type Error = anyhow::Error;\n\n    fn try_from(value: ProjectHandle) -> Result<Self, Self::Error> {\n        value.into_path()\n    }\n}\n\nfn encoded_str_to_path(encoded: &str) -> anyhow::Result<PathBuf> {\n    let bytes = decode(encoded)?;\n    let path = gix::path::try_from_byte_slice(&bytes)\n        .map_err(anyhow::Error::from)\n        .with_context(|| {\n            format!(\"Encoded ProjectHandle payload is not a valid filesystem path: '{encoded}'\")\n        })?;\n    if !path.is_absolute() {\n        bail!(\n            \"ProjectHandle payload must decode to an absolute filesystem path, got '{}'\",\n            path.display()\n        );\n    }\n    Ok(path.to_owned())\n}\n\nfn path_to_string(path: &Path) -> Result<String, anyhow::Error> {\n    let bytes = gix::path::os_str_into_bstr(path.as_os_str())?;\n    Ok(encode(bytes))\n}\n\nfn encode(bytes: &[u8]) -> String {\n    URL_SAFE_NO_PAD.encode(bytes)\n}\n\nfn decode(encoded: &str) -> anyhow::Result<Vec<u8>> {\n    URL_SAFE_NO_PAD","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-project-handle/src/project_handle.rs#L94-L130","documentation":"ProjectHandle payloads encode a filesystem path; this error fires when a decoded payload is not an absolute path. The library refuses relative paths because handles must unambiguously locate a project on disk regardless of the current working directory.","triggerScenarios":"Calling `encoded_str_to_path` indirectly through `ProjectHandle::to_path`, `from_str`, or round-trip helpers with a handle whose payload decodes to a relative path (e.g. 'foo/bar', '.', or an empty-ish path).","commonSituations":"Hand-crafting or copying ProjectHandle strings between machines; constructing handles from relative paths on older versions; pasting truncated handle strings; cross-platform moves where the drive prefix was lost.","solutions":["Use `Path::canonicalize()` (or `std::fs::absolute`) to make the path absolute before creating the handle","Regenerate the ProjectHandle from the absolute project path instead of editing the encoded string","Verify the decoded payload with a leading '/' (or Windows drive prefix) before passing it in","If migrating from an older format, re-encode handles with the current library version"],"exampleFix":"// before\nlet handle = ProjectHandle::from_str(\"some/relative/path\")?;\n// after\nlet abs = std::path::Path::new(\"some/relative/path\").canonicalize()?;\nlet handle = ProjectHandle::from_path(&abs)?;","handlingStrategy":"validation","validationCode":"fn ensure_absolute(p: &std::path::Path) -> anyhow::Result<()> {\n    anyhow::ensure!(p.is_absolute(), \"path must be absolute: {}\", p.display());\n    Ok(())\n}","typeGuard":"fn is_absolute_path(p: &std::path::Path) -> bool { p.is_absolute() }","tryCatchPattern":"match ProjectHandle::from_str(&raw) {\n    Ok(h) => h,\n    Err(e) if e.to_string().contains(\"absolute filesystem path\") => {\n        let abs = std::path::Path::new(&raw).canonicalize()?;\n        ProjectHandle::from_path(&abs)?\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Always construct handles from canonicalized absolute paths","Never hand-edit encoded handle strings","Round-trip test handles after migrating between machines"],"tags":["path","project-handle","validation"],"backgroundTag":"invalid-argument-format","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}