{"record":{"id":"31ec97a1bbfafba1","repo":"nautechsystems/nautilus_trader","slug":"failed-to-parse-databento-historical-api-base-url","errorCode":null,"errorMessage":"Failed to parse Databento Historical API base URL: {e}","messagePattern":"Failed to parse Databento Historical API base URL: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/databento/src/historical.rs","lineNumber":141,"sourceCode":"    /// Creates a new [`DatabentoHistoricalClient`] instance with a custom API base URL.\n    ///\n    /// This is intended for tests, benchmarks, and controlled deployments that route\n    /// Databento Historical API requests through a proxy.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if client creation, URL parsing, or publisher loading fails.\n    pub fn new_with_base_url(\n        credential: Credential,\n        publishers_filepath: PathBuf,\n        clock: &'static AtomicTime,\n        use_exchange_as_venue: bool,\n        base_url: &str,\n    ) -> anyhow::Result<Self> {\n        let client = databento::HistoricalClient::builder()\n            .user_agent_extension(NAUTILUS_USER_AGENT.into())\n            .base_url(base_url.parse().map_err(|e| {\n                anyhow::anyhow!(\"Failed to parse Databento Historical API base URL: {e}\")\n            })?)\n            .key(credential.api_key())\n            .map_err(|e| anyhow::anyhow!(\"Failed to create client builder: {e}\"))?\n            .build()\n            .map_err(|e| anyhow::anyhow!(\"Failed to build client: {e}\"))?;\n\n        Self::from_client(\n            credential,\n            publishers_filepath,\n            clock,\n            use_exchange_as_venue,\n            client,\n        )\n    }\n\n    fn from_client(\n        credential: Credential,\n        publishers_filepath: PathBuf,","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/databento/src/historical.rs#L123-L159","documentation":"Thrown when the `base_url` string passed to `new_with_base_url` cannot be parsed into the URL type the databento HistoricalClient builder expects. The parse error is embedded in the message. This only occurs on the base-URL variant of the constructor, not the default `new`.","triggerScenarios":"Calling `new_with_base_url(credential, ..., base_url)` with a string that is not a valid absolute URL (e.g. missing scheme, invalid characters).","commonSituations":"Pointing at a local mock/proxy server with 'localhost:8080' (missing http://), typo'd scheme ('htp://'), trailing garbage, or a config value that was meant to be host-only.","solutions":["Include the scheme: use 'https://...' or 'http://...' for the base URL","Trim whitespace and quotes from the URL before passing it","Validate the URL with `url::Url::parse` before calling the constructor","Check the config file/env var that supplies the base URL for typos"],"exampleFix":"// before\nlet base_url = \"localhost:8080\";\nclient.new_with_base_url(cred, path, clock, true, base_url)\n// after\nlet base_url = \"http://localhost:8080\";\nurl::Url::parse(base_url).expect(\"valid base url\");\nclient.new_with_base_url(cred, path, clock, true, base_url)","handlingStrategy":"validation","validationCode":"let parsed = url::Url::parse(base_url)?;\nif !matches!(parsed.scheme(), \"http\" | \"https\") {\n    return Err(anyhow::anyhow!(\"base_url must use http(s): {base_url}\"));\n}","typeGuard":"fn is_valid_base_url(s: &str) -> bool {\n    url::Url::parse(s).map(|u| matches!(u.scheme(), \"http\" | \"https\")).unwrap_or(false)\n}","tryCatchPattern":null,"preventionTips":["Always include an explicit http(s) scheme in configured base URLs","Pre-validate URLs with the url crate at config load time","Trim whitespace/quotes from config values","Keep base URLs in one config constant rather than scattered literals"],"tags":["rust","databento","url-parse","configuration"],"backgroundTag":"invalid-url-format","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}