{"record":{"id":"4f6a6f7bc360c6e7","repo":"nautechsystems/nautilus_trader","slug":"database-is-not-initialized","errorCode":null,"errorMessage":"Database is not initialized","messagePattern":"Database is not initialized","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/cli/src/blockchain/analyze.rs","lineNumber":443,"sourceCode":"        .iter()\n        .copied()\n        .filter(|&block| block <= to_block)\n        .collect();\n    checkpoints.sort_unstable();\n    checkpoints.dedup();\n    checkpoints\n}\n\nasync fn needs_bootstrap_before_target(\n    data_client: &BlockchainDataClientCore,\n    pool_identifier: &PoolIdentifier,\n    to_block: u64,\n) -> anyhow::Result<bool> {\n    let database = data_client\n        .cache\n        .database\n        .as_ref()\n        .ok_or_else(|| anyhow::anyhow!(\"Database is not initialized\"))?;\n    let snapshot = database\n        .load_latest_pool_snapshot(\n            data_client.chain.chain_id,\n            pool_identifier,\n            Some(to_block),\n            true,\n        )\n        .await?;\n\n    let Some(snapshot) = snapshot else {\n        return Ok(true);\n    };\n    let snapshot_needs_bootstrap = data_client\n        .cache\n        .get_pool(pool_identifier)\n        .is_some_and(|pool| is_empty_creation_snapshot(&snapshot, pool.creation_block));\n\n    Ok(snapshot_needs_bootstrap)","sourceCodeStart":425,"sourceCodeEnd":461,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/cli/src/blockchain/analyze.rs#L425-L461","documentation":"`needs_bootstrap_before_target` inspects the latest stored pool snapshot from the cache's backing database to decide whether a bootstrap pass is required. If `cache.database` is `None` (no persistent database configured on the data client), the check cannot run and this error is raised.","triggerScenarios":"Running pool analysis against a data client whose cache was constructed without a database (e.g. missing connection string/config, or an in-memory-only client), when the code reaches the bootstrap decision point.","commonSituations":"Forgetting to configure the nautilus PostgreSQL/cache database in the CLI config; running analysis in an environment where the DB-backed client factory was bypassed; a refactor/upgrade dropping the database from client construction.","solutions":["Configure a database on the data client (connection string/env config) so `cache.database` is `Some`.","Check the CLI's chain/database configuration files for missing connection settings.","Verify how the data client is built in the analyze command path and that the DB-backed constructor is used.","Inspect inner code to see whether the bootstrap check can be skipped legitimately for non-persistent runs."],"exampleFix":"// before: cache built without db\nlet cache = Cache::new(None);\n// after\nlet cache = Cache::new(Some(database.clone()));","handlingStrategy":"validation","validationCode":"if data_client.cache.database.is_none() {\n    anyhow::bail!(\"configure a database for pool analysis before running\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always construct the data client with a configured database for analysis commands.","Check connection config/env early at CLI startup with a clear failure."],"tags":["blockchain","database","configuration","cli"],"backgroundTag":"missing-configuration","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}