{"record":{"id":"a9331539634dfdd8","repo":"nautechsystems/nautilus_trader","slug":"failed-to-create-client-builder-e","errorCode":null,"errorMessage":"Failed to create client builder: {e}","messagePattern":"Failed to create client builder: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/databento/src/historical.rs","lineNumber":110,"sourceCode":"    pub fn api_key(&self) -> &str {\n        self.credential.api_key()\n    }\n\n    /// Creates a new [`DatabentoHistoricalClient`] instance.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if client creation or publisher loading fails.\n    pub fn new(\n        credential: Credential,\n        publishers_filepath: PathBuf,\n        clock: &'static AtomicTime,\n        use_exchange_as_venue: bool,\n    ) -> anyhow::Result<Self> {\n        let client = databento::HistoricalClient::builder()\n            .user_agent_extension(NAUTILUS_USER_AGENT.into())\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    /// 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","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/databento/src/historical.rs#L92-L128","documentation":"DatabentoHistoricalClient::new builds the underlying databento::HistoricalClient via its builder. If the builder construction itself fails (before even building the client), the error is wrapped with this message, indicating a problem with builder initialization such as an invalid API key credential format.","triggerScenarios":"Calling DatabentoHistoricalClient::new with a credential whose api_key() cannot be applied to the builder (databento crate rejects the key format/empty key at builder stage).","commonSituations":"Malformed or empty Databento API key supplied as the credential; incompatible databento crate version producing builder errors; whitespace/encoding issues in the stored key.","solutions":["Validate the API key is non-empty and correctly formatted before constructing the client","Inspect the wrapped source error for the underlying builder failure reason","Re-create the credential from a valid DATABENTO_API_KEY","Check databento crate version compatibility with the adapter"],"exampleFix":"// before\nlet client = DatabentoHistoricalClient::new(credential, publishers, clock, use_exchange_as_venue)?;\n// after\nassert!(!credential.api_key().is_empty(), \"Databento API key must not be empty\");\nlet client = DatabentoHistoricalClient::new(credential, publishers, clock, use_exchange_as_venue)?;","handlingStrategy":"validation","validationCode":"// Rust\nif credential.api_key().trim().is_empty() { bail!(\"key required\"); }","typeGuard":null,"tryCatchPattern":"// Rust\nErr(e) => error!(\"init: {e:#}\"),","preventionTips":["Validate key format","Log full chains","Align crate versions","Use secret store"],"tags":["rust","databento","historical","client-builder"],"backgroundTag":"api-request-failed","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"}