{"record":{"id":"c5e06c97ce98778e","repo":"nautechsystems/nautilus_trader","slug":"unknown-chain-id-chain-id","errorCode":null,"errorMessage":"Unknown chain_id: {chain_id}","messagePattern":"Unknown chain_id: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/cache/database.rs","lineNumber":2536,"sourceCode":"                .await?;\n\n            let ticks = self\n                .load_pool_ticks_for_snapshot(\n                    chain_id,\n                    pool_identifier,\n                    block,\n                    transaction_index,\n                    log_index,\n                )\n                .await?;\n\n            let dex_name = row\n                .try_get::<Option<String>, _>(\"dex_name\")?\n                .ok_or_else(|| {\n                    anyhow::anyhow!(\"Missing dex_name for pool snapshot {}\", pool_identifier)\n                })?;\n            let chain = Chain::from_chain_id(chain_id)\n                .ok_or_else(|| anyhow::anyhow!(\"Unknown chain_id: {chain_id}\"))?;\n\n            let dex_type = DexType::from_dex_name(&dex_name)\n                .ok_or_else(|| anyhow::anyhow!(\"Unknown dex_name: {dex_name}\"))?;\n\n            let dex_extended = crate::exchanges::get_dex_extended(chain.name, &dex_type)\n                .ok_or_else(|| {\n                    anyhow::anyhow!(\"No DEX extended found for {} on {}\", dex_name, chain.name)\n                })?;\n\n            let instrument_id =\n                Pool::create_instrument_id(chain.name, &dex_extended.dex, pool_identifier.as_ref());\n\n            Ok(Some(PoolSnapshot::new(\n                instrument_id,\n                state,\n                positions,\n                ticks,\n                analytics,","sourceCodeStart":2518,"sourceCodeEnd":2554,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/cache/database.rs#L2518-L2554","documentation":"The snapshot row's `chain_id` integer does not map to any known `Chain` in the library's chain registry (`Chain::from_chain_id` returned None). The loader cannot determine which blockchain the snapshot belongs to, so it fails. This guards against rows written for chains the current build does not support.","triggerScenarios":"A snapshot row persisted with a chain_id that the current binary's `Chain` enum/registry doesn't recognize — e.g. a newer chain added by a different adapter version, a test/dev chain id, or a typo'd chain id written by custom code.","commonSituations":"Running an older adapter version against a database written by a newer version that supports extra chains; custom fork with an added EVM chain; misconfigured deployment pointing the adapter at another network's database.","solutions":["Upgrade to an adapter version whose `Chain` registry includes the offending chain_id.","Check the chain_id value in the row against supported chains; delete the row if it was written in error.","Verify the deployment is pointed at the database for the intended network.","Log the full set of supported chain_ids and add the new chain upstream if it's legitimately needed."],"exampleFix":"// before: chain added only in DB, not in code\nlet chain = Chain::from_chain_id(chain_id).ok_or_else(...)?;\n// after: extend the registry in the source of truth\n// chain_registry.rs\n(11155111, Chain::EthereumSepolia), // add missing chain id","handlingStrategy":"validation","validationCode":"// before loading, verify every chain_id in the table is supported\nlet bad: Vec<i32> = sqlx::query_scalar(\n    \"SELECT DISTINCT chain_id FROM pool_snapshots\")\n    .fetch_all(&db).await?\n    .into_iter().filter(|id| Chain::from_chain_id(*id as u64).is_none()).collect();\nif !bad.is_empty() { return Err(format!(\"unsupported chain_ids: {bad:?}\")); }","typeGuard":null,"tryCatchPattern":"match load_snapshot(...).await {\n    Err(e) if e.to_string().contains(\"Unknown chain_id\") => {\n        tracing::error!(\"upgrade adapter or purge rows for unsupported chain\");\n        Err(e)\n    }\n    other => other,\n}","preventionTips":["Keep writer and reader adapter versions aligned across deployments.","Validate chain_id against the supported list before persisting snapshots.","Document and gate new-chain support behind matching registry updates."],"tags":["configuration","chain-registry","version-mismatch","snapshot-loading"],"backgroundTag":"invalid-enum-value","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"}