gitbutlerapp/gitbutler · error

No host in URL

Error message

No host in {} URL

What it means

validate_gitbutler_url parses a URL and extracts its host to check it against a trusted-domain predicate. If the parsed URL has no host (e.g. a scheme like file:// or a malformed URL), it throws "No host in {} URL" where {} is the url_type (e.g. "API URL"). This is part of the SSRF/redirect protection for release and download URLs.

Solutions

  1. Ensure any custom release API or download URL is a fully qualified http(s) URL with a host
  2. Remove custom URL overrides so the defaults (api.gitbutler.com / GitHub releases) are used
  3. If triggered by a redirect, the installer rejected it by design — do not bypass; report the redirect source

Example fix

// before
let api_url = "file:///mirror/release-api";
// after
let api_url = "https://api.example-mirror.dev/releases";
Defensive patterns

Strategy: validation

Validate before calling

// validate URL shape before use
let parsed = url::Url::parse(candidate)?;
if parsed.host_str().is_none() {
    return Err(format!("URL must be absolute http(s) with a host: {candidate}"));
}

Prevention

When it happens

Trigger: validate_api_url or validate_download_url called with a URL string that parses but has no host component (e.g. "file:///etc/passwd", "unix:/path", or a relative string that happens to parse).

Common situations: A malicious or misconfigured redirect target, a corrupted release-metadata URL, or overriding the API/download URL with a non-HTTP scheme in a custom config.

Understand the failure class

Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18). Data as JSON: /api/errors/d845cbda48c23bbf. Report an issue: GitHub.

Appendix: source

Thrown at crates/but-installer/src/release.rs:112

/// Common URL validation logic for GitButler domains.
///
/// Validates HTTPS protocol, parses URL, and checks the host against a predicate.
fn validate_gitbutler_url(
    url: &str,
    url_type: &str,
    is_host_valid: impl Fn(&str) -> bool,
) -> Result<()> {
    // Only allow HTTPS URLs
    if !url.starts_with("https://") {
        bail!("{url_type} must use HTTPS: {url}");
    }

    // Extract host from URL
    let url_parsed =
        url::Url::parse(url).with_context(|| format!("Invalid {} URL", url_type.to_lowercase()))?;
    let host = url_parsed
        .host_str()
        .ok_or_else(|| anyhow!("No host in {} URL", url_type.to_lowercase()))?;

    // Validate host using the provided predicate
    if !is_host_valid(host) {
        bail!("{url_type} is not from a trusted GitButler domain: {url}");
    }

    Ok(())
}

/// Validates that an API URL is from the trusted API domain.
///
/// API endpoints should only be served from app.gitbutler.com to prevent
/// redirecting API requests to other subdomains.
pub(crate) fn validate_api_url(url: &str) -> Result<()> {
    validate_gitbutler_url(url, "API URL", |host| host == "app.gitbutler.com")
}

/// Validates that a download URL is from a trusted GitButler domain.

View on GitHub (pinned to 58e5313667)