gitbutlerapp/gitbutler · error

Ollama endpoint must use host:port format

Error message

Ollama endpoint must use host:port format

What it means

Validation guard in validate_ollama_endpoint: the Ollama endpoint must be a bare host:port address, but the supplied string contained a URL scheme separator (e.g. 'http://'), which the local Ollama client does not accept. Fires during config validation (validate, validate_active) or when applying Ollama configuration; the user should strip the scheme and provide only host:port.

Solutions

  1. Remove the http:// or https:// prefix from the endpoint
  2. Use host:port form, e.g. localhost:11434
  3. If a hostname without port was intended, append the Ollama default port 11434

Example fix

// before
ollama.endpoint = "http://localhost:11434"
// after
ollama.endpoint = "localhost:11434"
Defensive patterns

Strategy: validation

Validate before calling

// TS
const isHostPort = (v: string) => !v.includes('://') && /^[^:]+:\d+$/.test(v);

Prevention

When it happens

Trigger: Setting the Ollama endpoint to "http://localhost:11434" instead of "localhost:11434" and running validate, validate_active, or apply_ollama_configuration.

Common situations: Copy-pasting the full Ollama URL from browser/docs into a field that only accepts host:port; mixing conventions with other providers' URL fields.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


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

Appendix: source

Thrown at crates/but-llm/src/config.rs:417

    if value.is_empty() {
        bail!("{field} is required")
    }
    Ok(value)
}

fn validate_url(value: &str, field: &str) -> Result<()> {
    let value = required(value, field)?;
    let url = url::Url::parse(value).with_context(|| format!("{field} must be a valid URL"))?;
    if !matches!(url.scheme(), "http" | "https") || url.host_str().is_none() {
        bail!("{field} must be an HTTP or HTTPS URL")
    }
    Ok(())
}

fn validate_ollama_endpoint(value: &str) -> Result<()> {
    let value = required(value, "Ollama endpoint")?;
    if value.contains("://") {
        bail!("Ollama endpoint must use host:port format")
    }
    let (host, port) = value
        .rsplit_once(':')
        .context("Ollama endpoint must use host:port format")?;
    if host.trim().is_empty() || port.parse::<u16>().is_err() {
        bail!("Ollama endpoint must use host:port format")
    }
    Ok(())
}

fn set_optional(config: &mut gix::config::File, key: &str, value: Option<&str>) -> Result<()> {
    match nonempty(value) {
        Some(value) => set_config_value(config, key, value),
        None => remove_config_value(config, key),
    }
}

#[cfg(test)]

View on GitHub (pinned to 58e5313667)