{"record":{"id":"db21129f7730f976","repo":"nautechsystems/nautilus_trader","slug":"api-key-is-required","errorCode":null,"errorMessage":"API key is required","messagePattern":"API key is required","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"critical","filePath":"crates/adapters/databento/src/factories.rs","lineNumber":226,"sourceCode":"        self\n    }\n\n    /// Sets whether to timestamp bars on close.\n    #[must_use]\n    pub const fn bars_timestamp_on_close(mut self, timestamp_on_close: bool) -> Self {\n        self.bars_timestamp_on_close = timestamp_on_close;\n        self\n    }\n\n    /// Builds the [`DatabentoDataClientConfig`].\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if required fields are missing.\n    pub fn build(self) -> anyhow::Result<DatabentoDataClientConfig> {\n        let api_key = self\n            .api_key\n            .ok_or_else(|| anyhow::anyhow!(\"API key is required\"))?;\n        let publishers_filepath = self\n            .publishers_filepath\n            .ok_or_else(|| anyhow::anyhow!(\"Publishers filepath is required\"))?;\n\n        Ok(DatabentoDataClientConfig::new(\n            api_key.into_inner(),\n            publishers_filepath,\n            self.use_exchange_as_venue,\n            self.bars_timestamp_on_close,\n        ))\n    }\n}\n\n#[cfg(test)]\nmod tests {\n    use nautilus_core::time::get_atomic_clock_realtime;\n    use rstest::rstest;\n","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/databento/src/factories.rs#L208-L244","documentation":"DatabentoDataClientConfigBuilder::build validates required fields; the Databento API key is mandatory for authentication with the Databento gateway. If api_key was never set on the builder, build() fails with this error before any client is created.","triggerScenarios":"Constructing DatabentoDataClientConfig via its builder without calling .api_key(...) — e.g. an empty/unset DATABENTO_API_KEY env var feeding the builder, or a config file missing the key field.","commonSituations":"Missing or misspelled DATABENTO_API_KEY environment variable; empty env var read as None; config YAML/TOML without the api_key entry; running in CI where secrets are not injected.","solutions":["Set the DATABENTO_API_KEY environment variable with a valid key from your Databento account","Call .api_key(...) explicitly on the builder before build()","Verify the env var is present and non-empty in the runtime environment (CI, container, shell profile)","Check config file loading so the api_key field is actually parsed and passed to the builder"],"exampleFix":"// before\nlet config = DatabentoDataClientConfig::builder().publishers_filepath(path).build()?;\n// after\nlet key = std::env::var(\"DATABENTO_API_KEY\")?;\nlet config = DatabentoDataClientConfig::builder().api_key(key).publishers_filepath(path).build()?;","handlingStrategy":"validation","validationCode":"// Rust\nif std::env::var(\"DATABENTO_API_KEY\").map_or(true, |k| k.trim().is_empty()) { bail!(\"key required\"); }","typeGuard":null,"tryCatchPattern":"// Rust\nErr(e) => error!(\"config: {e:#}\"),","preventionTips":["Set env var everywhere","Fail fast on empty","Verify CI secrets","Check config files"],"tags":["rust","databento","api-key","config"],"backgroundTag":"missing-api-key","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"}