{"record":{"id":"555e18a91f610b52","repo":"linera-io/linera-protocol","slug":"chain-chain-id-not-found","errorCode":null,"errorMessage":"Chain {chain_id} not found.","messagePattern":"Chain (.+?) not found\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"linera-wallet-json/src/display.rs","lineNumber":25,"sourceCode":"    data_types::{ChainDescription, ChainOrigin},\n    identifiers::ChainId,\n};\nuse linera_core::wallet;\n\nuse crate::wallet::Data;\n\nstruct ChainDetails {\n    is_default: bool,\n    is_admin: bool,\n    origin: Option<ChainOrigin>,\n    chain_id: ChainId,\n    user_chain: wallet::Chain,\n}\n\nimpl ChainDetails {\n    fn new(chain_id: ChainId, data: &Data) -> Self {\n        let Some(user_chain) = data.chains.get(chain_id) else {\n            panic!(\"Chain {chain_id} not found.\");\n        };\n        ChainDetails {\n            is_default: Some(chain_id) == *data.default.read().unwrap(),\n            is_admin: chain_id == data.genesis_config.admin_chain_id(),\n            chain_id,\n            origin: data\n                .genesis_config\n                .chains\n                .iter()\n                .find(|description| description.id() == chain_id)\n                .map(ChainDescription::origin),\n            user_chain,\n        }\n    }\n\n    fn print_paragraph(&self) {\n        println!(\"-----------------------\");\n        println!(\"{:<20}  {}\", \"Chain ID:\", self.chain_id);","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/linera-io/linera-protocol/blob/6c226ddcb332ef55118dc8d0aafbd093d5420899/linera-wallet-json/src/display.rs#L7-L43","documentation":"ChainDetails::new is used by wallet display code to render each chain. It looks the chain up in the wallet's chains map and panics if the id is absent. This is an internal consistency check: the wallet file (linera-wallet.json) should always contain every chain that is being displayed, including the default and admin chains.","triggerScenarios":"Printing wallet contents when a referenced chain id is not in data.chains — typically because the wallet JSON was hand-edited, corrupted, partially written by two concurrent commands, or the default chain points to a chain that was removed.","commonSituations":"Running two linera CLI commands that both write the wallet at once; manually editing or restoring an older wallet file while keeping a newer config; scripts deleting chain entries; interrupted wallet updates.","solutions":["Restore wallet consistency: re-initialize or update the wallet (e.g. linera wallet init / re-adding the chain) so every referenced chain id has an entry","Never run two wallet-mutating linera commands concurrently","Keep backups of linera-wallet.json before manual edits and validate the JSON afterwards","If the wallet is corrupted, regenerate it from the genesis/config and re-add your chains"],"exampleFix":"# before\n# wallet JSON edited by hand: default_chain points to a removed chain\nlinera wallet show   # panics: Chain e5... not found.\n\n# after\n# re-add the missing chain (or fix the default chain id), then\nlinera wallet show","handlingStrategy":"validation","validationCode":"// Before displaying the wallet, check consistency:\nfor chain_id in [data.default.read().unwrap().expect(\"default chain\"), admin_chain_id] {\n    assert!(data.chains.contains_key(&chain_id), \"wallet missing entry for {chain_id}\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Serialize wallet-mutating CLI commands (flock or a single wrapper script)","Back up linera-wallet.json before hand edits and validate it loads afterwards","Recreate the wallet from genesis instead of patching entries ad hoc"],"tags":["wallet","cli","state-consistency","chain-id"],"backgroundTag":"chain-not-found-in-wallet","analyzedSha":"6c226ddcb332ef55118dc8d0aafbd093d5420899","analyzedAt":"2026-08-22T22:49:09.787Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}