vectordotdev/vector · error

Couldn't parse default API URL. Please report this.

Error message

Couldn't parse default API URL. Please report this.

What it means

`default_grpc_url` formats the default API address as a URL string and parses it with `Url::parse`, asserting success because the constant is hard-coded. A panic here means the built-in default address constant itself is malformed — hence "Please report this".

Solutions

  1. Inspect your patched/overridden `default_address()` value and fix it to a valid host:port form.
  2. If using stock Vector, report the bug upstream — the default is expected to always parse.
  3. As a workaround, set the API address explicitly in configuration instead of relying on the default.

Example fix

// before (patched constant)
fn default_address() -> Option<SocketAddr> { Some("127.0.0.1 noport".parse().unwrap()) }
// after
fn default_address() -> Option<SocketAddr> { Some("127.0.0.1:8686".parse().unwrap()) }
Defensive patterns

Strategy: validation

Validate before calling

let parsed = url::Url::parse(&format!("http://{}", addr));
assert!(parsed.is_ok(), "default API address {addr} is not a valid URL");

Type guard

fn is_parsable_url(s: &str) -> bool { url::Url::parse(s).is_ok() }

Try / catch

let url = match url::Url::parse(&format!("http://{addr}")) { Ok(u) => u, Err(e) => { eprintln!("bad default url: {e}"); return; } };

Prevention

When it happens

Trigger: Any call to `default_grpc_url()` (e.g. `vector top`, API client defaults, config deserialization using serde default) when the compiled-in default address no longer parses as a URL.

Common situations: Patching `default_address()` to a custom value containing invalid URL characters (spaces, missing port, bad scheme); broken downstream builds that override the constant.

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 vectordotdev/vector@bdb87aeaa4 (2026-09-16). Data as JSON: /api/errors/bbf559f506bde227. Report an issue: GitHub.

Appendix: source

Thrown at src/config/api.rs:55

    }
}

const fn default_enabled() -> bool {
    false
}

/// By default, the API binds to 127.0.0.1:8686. This function should remain public;
/// `vector top`  will use it to determine which to connect to by default, if no URL
/// override is provided.
pub fn default_address() -> Option<SocketAddr> {
    Some(SocketAddr::new(Ipv4Addr::LOCALHOST.into(), 8686))
}

/// Default gRPC API address for `vector top` and other API clients
pub fn default_grpc_url() -> Url {
    let addr = default_address().unwrap();
    Url::parse(&format!("http://{addr}"))
        .expect("Couldn't parse default API URL. Please report this.")
}

impl Options {
    pub fn merge(&mut self, other: Self) -> Result<(), String> {
        // Merge options

        // Try to merge address
        let address = match (self.address, other.address) {
            (None, b) => b,
            (Some(a), None) => Some(a),
            (Some(a), Some(b)) if a == b => Some(a),
            // Prefer non default address
            (Some(a), Some(b)) => {
                match (Some(a) == default_address(), Some(b) == default_address()) {
                    (false, false) => return Err(format!("Conflicting `api` address: {a}, {b} .")),
                    (false, true) => Some(a),
                    (true, _) => Some(b),
                }

View on GitHub (pinned to bdb87aeaa4)