gitbutlerapp/gitbutler · error
ProjectHandle payload must decode to an absolute filesystem…
Error message
ProjectHandle payload must decode to an absolute filesystem path, got '{}' What it means
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.
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
Example fix
// before
let handle = ProjectHandle::from_str("some/relative/path")?;
// after
let abs = std::path::Path::new("some/relative/path").canonicalize()?;
let handle = ProjectHandle::from_path(&abs)?; Defensive patterns
Strategy: validation
Validate before calling
fn ensure_absolute(p: &std::path::Path) -> anyhow::Result<()> {
anyhow::ensure!(p.is_absolute(), "path must be absolute: {}", p.display());
Ok(())
} Type guard
fn is_absolute_path(p: &std::path::Path) -> bool { p.is_absolute() } Try / catch
match ProjectHandle::from_str(&raw) {
Ok(h) => h,
Err(e) if e.to_string().contains("absolute filesystem path") => {
let abs = std::path::Path::new(&raw).canonicalize()?;
ProjectHandle::from_path(&abs)?
}
Err(e) => return Err(e),
} Prevention
- Always construct handles from canonicalized absolute paths
- Never hand-edit encoded handle strings
- Round-trip test handles after migrating between machines
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- CLI destination must be absolute
- CLI source path must be absolute
- not a git repository
- Path does not exist
- project path is not a directory
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/584dfd0060baae1c.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but-project-handle/src/project_handle.rs:112
}
impl TryFrom<ProjectHandle> for PathBuf {
type Error = anyhow::Error;
fn try_from(value: ProjectHandle) -> Result<Self, Self::Error> {
value.into_path()
}
}
fn encoded_str_to_path(encoded: &str) -> anyhow::Result<PathBuf> {
let bytes = decode(encoded)?;
let path = gix::path::try_from_byte_slice(&bytes)
.map_err(anyhow::Error::from)
.with_context(|| {
format!("Encoded ProjectHandle payload is not a valid filesystem path: '{encoded}'")
})?;
if !path.is_absolute() {
bail!(
"ProjectHandle payload must decode to an absolute filesystem path, got '{}'",
path.display()
);
}
Ok(path.to_owned())
}
fn path_to_string(path: &Path) -> Result<String, anyhow::Error> {
let bytes = gix::path::os_str_into_bstr(path.as_os_str())?;
Ok(encode(bytes))
}
fn encode(bytes: &[u8]) -> String {
URL_SAFE_NO_PAD.encode(bytes)
}
fn decode(encoded: &str) -> anyhow::Result<Vec<u8>> {
URL_SAFE_NO_PADView on GitHub (pinned to 58e5313667)