{"record":{"id":"bbf559f506bde227","repo":"vectordotdev/vector","slug":"couldn-t-parse-default-api-url-please-report-this","errorCode":null,"errorMessage":"Couldn't parse default API URL. Please report this.","messagePattern":"Couldn't parse default API URL\\. Please report this\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/config/api.rs","lineNumber":55,"sourceCode":"    }\n}\n\nconst fn default_enabled() -> bool {\n    false\n}\n\n/// By default, the API binds to 127.0.0.1:8686. This function should remain public;\n/// `vector top`  will use it to determine which to connect to by default, if no URL\n/// override is provided.\npub fn default_address() -> Option<SocketAddr> {\n    Some(SocketAddr::new(Ipv4Addr::LOCALHOST.into(), 8686))\n}\n\n/// Default gRPC API address for `vector top` and other API clients\npub fn default_grpc_url() -> Url {\n    let addr = default_address().unwrap();\n    Url::parse(&format!(\"http://{addr}\"))\n        .expect(\"Couldn't parse default API URL. Please report this.\")\n}\n\nimpl Options {\n    pub fn merge(&mut self, other: Self) -> Result<(), String> {\n        // Merge options\n\n        // Try to merge address\n        let address = match (self.address, other.address) {\n            (None, b) => b,\n            (Some(a), None) => Some(a),\n            (Some(a), Some(b)) if a == b => Some(a),\n            // Prefer non default address\n            (Some(a), Some(b)) => {\n                match (Some(a) == default_address(), Some(b) == default_address()) {\n                    (false, false) => return Err(format!(\"Conflicting `api` address: {a}, {b} .\")),\n                    (false, true) => Some(a),\n                    (true, _) => Some(b),\n                }","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/src/config/api.rs#L37-L73","documentation":"`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\".","triggerScenarios":"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.","commonSituations":"Patching `default_address()` to a custom value containing invalid URL characters (spaces, missing port, bad scheme); broken downstream builds that override the constant.","solutions":["Inspect your patched/overridden `default_address()` value and fix it to a valid host:port form.","If using stock Vector, report the bug upstream — the default is expected to always parse.","As a workaround, set the API address explicitly in configuration instead of relying on the default."],"exampleFix":"// before (patched constant)\nfn default_address() -> Option<SocketAddr> { Some(\"127.0.0.1 noport\".parse().unwrap()) }\n// after\nfn default_address() -> Option<SocketAddr> { Some(\"127.0.0.1:8686\".parse().unwrap()) }","handlingStrategy":"validation","validationCode":"let parsed = url::Url::parse(&format!(\"http://{}\", addr));\nassert!(parsed.is_ok(), \"default API address {addr} is not a valid URL\");","typeGuard":"fn is_parsable_url(s: &str) -> bool { url::Url::parse(s).is_ok() }","tryCatchPattern":"let url = match url::Url::parse(&format!(\"http://{addr}\")) { Ok(u) => u, Err(e) => { eprintln!(\"bad default url: {e}\"); return; } };","preventionTips":["Never patch default_address()/default_grpc_url constants with unvalidated strings.","Set the API address explicitly in your vector config rather than relying on defaults in embedded deployments.","Add a compile-time/unit test that the default parses."],"tags":["url","config","default-value"],"backgroundTag":"invalid-url-format","analyzedSha":"bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013","analyzedAt":"2026-09-16T02:53:35.741Z","contentChangedAt":"2026-09-16T02:53:35.741Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}