Skip to content

Conversation

@themavik
Copy link

@themavik themavik commented Feb 9, 2026

Summary

Fixes #12272.

Root cause: show_in_finder() on Linux passes bare filesystem paths (e.g., /home/me/Projects/Launcher/Launcher) directly to open_that(). The open_that() function parses its input with Url::parse(), which requires a valid URL with a scheme. Bare filesystem paths lack a scheme and fail with the error: Invalid path format: '...' → relative URL without a base.

Note: This only affects Linux. On macOS and Windows, show_in_finder() uses Command::new("open") and Command::new("explorer") respectively, bypassing open_that() entirely.

Fix: Two minimal changes:

  1. Convert filesystem paths to file:// URLs using Url::from_file_path() in the Linux block of show_in_finder(), so open_that() receives a valid URL.
  2. Add "file" to the allowed URL schemes in open_that() so file:// URLs pass the scheme validation.

Changes

  • crates/but-api/src/legacy/open.rs:
    • open_that(): Added "file" to the allowed URL schemes whitelist.
    • show_in_finder() (Linux block): Refactored to convert the target directory path to a file:// URL via Url::from_file_path() before passing to open_that(). This ensures xdg-open receives a properly formatted URL.

Root Cause Analysis

The open_that() function was designed for opening URLs (http, https, vscode://, etc.) and performs URL parsing + scheme validation. When show_in_finder() on Linux was implemented, it reused open_that() for filesystem paths without converting them to URLs first. macOS and Windows code paths use direct Command::new() calls and don't go through open_that(), which is why this bug is Linux-specific.

Risk Assessment

  • Low risk: The file scheme is safe — it only opens the system file manager via xdg-open.
  • No behavior change on macOS or Windows, since they don't use open_that() for file manager operations.
  • AppImage env cleaning is preserved since open_that() still handles the command execution.

…itbutlerapp#12272)

Root cause: show_in_finder() on Linux passes bare filesystem paths
(e.g., '/home/me/Projects/...') to open_that(), which parses them with
Url::parse(). Bare paths are not valid URLs and fail with 'relative URL
without a base'.

Fix: Convert filesystem paths to file:// URLs using Url::from_file_path()
before passing to open_that(), and add 'file' to the allowed URL schemes.
This ensures xdg-open receives a properly formatted file:// URL.
@github-actions github-actions bot added the rust Pull requests that update Rust code label Feb 9, 2026
@vercel
Copy link

vercel bot commented Feb 9, 2026

@themavik is attempting to deploy a commit to the GitButler Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

'Show in File Manager' throws 'Invalid path format' error

1 participant