{"record":{"id":"dc9d8590f22f21b2","repo":"linera-io/linera-protocol","slug":"badinitialization","errorCode":"BadInitialization","errorMessage":"ExporterError::BadInitialization","messagePattern":"ExporterError::BadInitialization","errorType":"exception","errorClass":"ExporterError","httpStatus":null,"severity":"error","filePath":"linera-exporter/src/state.rs","lineNumber":119,"sourceCode":"                .map_err(|e| ExporterError::GenericError(e.into()))?;\n            if block.height == expected_block_height {\n                *last_processed = block.into();\n                return Ok(true);\n            }\n            tracing::warn!(\n                ?expected_block_height,\n                ?block,\n                \"attempted to index a block out of order\",\n            );\n            Ok(false)\n        } else {\n            Err(ExporterError::UnprocessedChain)\n        }\n    }\n\n    /// Registers a chain from its initial block at height zero.\n    pub async fn initialize_chain(&mut self, block: BlockId) -> Result<(), ExporterError> {\n        ensure!(\n            block.height == BlockHeight::ZERO,\n            ExporterError::BadInitialization\n        );\n\n        if self.chain_states.contains_key(&block.chain_id).await? {\n            Err(ExporterError::ChainAlreadyExists(block.chain_id))?\n        }\n\n        let chain_id = block.chain_id;\n        self.chain_states.insert(&chain_id, block.into())?;\n        Ok(())\n    }\n\n    /// Returns the highest block already processed for the given chain, if any.\n    pub async fn get_chain_status(\n        &self,\n        chain_id: &ChainId,\n    ) -> Result<Option<LiteBlockId>, ExporterError> {","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/linera-io/linera-protocol/blob/6c226ddcb332ef55118dc8d0aafbd093d5420899/linera-exporter/src/state.rs#L101-L137","documentation":"The Linera exporter learns new chains only from their very first block. ExporterState::initialize_chain registers a chain from its initial block and enforces block.height == BlockHeight::ZERO; BadInitialization here means you tried to register a chain starting from a block at height greater than zero.","triggerScenarios":"Calling initialize_chain (directly or through the storage layer's indexing path) with a BlockId whose height is not zero — e.g. an exporter that starts indexing a chain from a later block because it never observed the height-0 block.","commonSituations":"Exporter pointed at an already-running network so the first block it sees for a chain is not block 0; exporter configured to start from a non-zero height; genesis/early blocks pruned from the source storage.","solutions":["Point the exporter at the chain's height-0 block (start export from the beginning of the chain)","Make sure the exporter's source node can serve block 0 for every chain it registers","If starting mid-chain is intentional, pre-register the chain in the exporter state first and then index the later blocks — never route a non-zero height into initialize_chain"],"exampleFix":"// before\nexporter_state.initialize_chain(block_id).await?; // BadInitialization when height > 0\n\n// after\nif block_id.height == BlockHeight::ZERO {\n    exporter_state.initialize_chain(block_id).await?;\n} else {\n    // chain must already be registered; index the block instead\n    exporter_storage.index_block(block_id).await?;\n}","handlingStrategy":"validation","validationCode":"use linera_base::identifiers::BlockHeight;\n\n// before registering a chain in the exporter:\nif block_id.height != BlockHeight::ZERO {\n    anyhow::bail!(\"initialize_chain requires the height-0 block, got height {}\", block_id.height);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run the exporter from the genesis block of each chain","Verify the exporter's start-height configuration is 0/beginning","Watch exporter logs for UnprocessedChain: a chain first seen above height 0 eventually hits this error"],"tags":["exporter","block-height","genesis","linera-exporter"],"backgroundTag":"initialization-height-mismatch","analyzedSha":"6c226ddcb332ef55118dc8d0aafbd093d5420899","analyzedAt":"2026-08-22T22:49:09.787Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}