{"record":{"id":"3f945ad90cf6e5b7","repo":"gitbutlerapp/gitbutler","slug":"failed-to-parse-url","errorCode":null,"errorMessage":"Failed to parse URL","messagePattern":"Failed to parse URL","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-api/src/open/mod.rs","lineNumber":630,"sourceCode":"            .with_context(|| format!(\"Failed to show '{path}' in Finder\"))?;\n    }\n\n    #[cfg(target_os = \"windows\")]\n    {\n        use std::process::Command;\n        Command::new(\"explorer\")\n            .arg(\"/select,\")\n            .arg(&path)\n            .status()\n            .with_context(|| format!(\"Failed to show '{path}' in Explorer\"))?;\n    }\n\n    #[cfg(target_os = \"linux\")]\n    {\n        // For directories, open the directory directly\n        if std::path::Path::new(&path).is_dir() {\n            open_that(\n                &Url::from_file_path(&path).map_err(|_| anyhow::anyhow!(\"Failed to parse URL\"))?,\n            )\n            .with_context(|| format!(\"Failed to open directory '{path}' in file manager\"))?;\n        } else {\n            // For files, try to open the parent directory\n            if let Some(parent) = std::path::Path::new(&path).parent() {\n                open_that(\n                    &Url::from_file_path(parent)\n                        .map_err(|_| anyhow::anyhow!(\"Failed to parse URL\"))?,\n                )\n                .with_context(|| {\n                    format!(\"Failed to open parent directory of '{path}' in file manager\",)\n                })?;\n            } else {\n                open_that(\n                    &Url::from_file_path(&path)\n                        .map_err(|_| anyhow::anyhow!(\"Failed to parse URL\"))?,\n                )\n                .with_context(|| format!(\"Failed to open '{path}' in file manager\"))?;","sourceCodeStart":612,"sourceCodeEnd":648,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-api/src/open/mod.rs#L612-L648","documentation":"On Linux, show_in_finder opens directories in the file manager by converting the path to a file:// URL with Url::from_file_path and passing it to open_that. from_file_path only accepts absolute paths, so it returns Err for relative paths, and the code maps that to the bare message 'Failed to parse URL'.","triggerScenarios":"Calling show_in_finder on Linux with a directory path that is relative (does not start with '/') or otherwise not convertible to a file:// URL (e.g. contains invalid characters that percent-encoding cannot represent, or an empty string).","commonSituations":"Caller passes a path derived from a truncated/relative cwd; frontend sends a workspace-relative path instead of an absolute one; path string empty or containing NUL/unsupported bytes after serialization.","solutions":["Pass an absolute path: canonicalize with `std::fs::canonicalize(&path)` before calling show_in_finder.","Check the caller that constructs the path and ensure it joins with the project root when the path is relative.","Validate the path is non-empty and starts with '/' before invoking the API.","If the path contains odd characters, confirm the value wasn't truncated or mangled upstream (e.g. by shell quoting)."],"exampleFix":"// before\nshow_in_finder(\"target/debug\") // relative -> Failed to parse URL\n// after\nlet abs = std::fs::canonicalize(\"target/debug\")?;\nshow_in_finder(&abs.to_string_lossy()) // file:///.../target/debug","handlingStrategy":"validation","validationCode":"import * as path from 'path';\nif (!path.isAbsolute(dirPath) || dirPath.length === 0) {\n  dirPath = path.resolve(dirPath); // make absolute before calling show_in_finder\n}","typeGuard":null,"tryCatchPattern":"try {\n  await showInFinder(dirPath);\n} catch (e) {\n  if (String(e).includes('Failed to parse URL')) {\n    showToast('Cannot open: path must be absolute. Re-resolving from project root...');\n  } else throw e;\n}","preventionTips":["Always canonicalize/resolve paths to absolute form at the caller boundary.","Never forward raw cwd-relative paths from tools or shell integrations.","Validate non-empty, absolute paths in UI forms before invoking."],"tags":["linux","url","path","absolute-path"],"backgroundTag":"invalid-url-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"}