linera-io/linera-protocol · error
Chain {chain_id} not found.
Error message
Chain {chain_id} not found. What it means
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.
Source
Thrown at linera-wallet-json/src/display.rs:25
data_types::{ChainDescription, ChainOrigin},
identifiers::ChainId,
};
use linera_core::wallet;
use crate::wallet::Data;
struct ChainDetails {
is_default: bool,
is_admin: bool,
origin: Option<ChainOrigin>,
chain_id: ChainId,
user_chain: wallet::Chain,
}
impl ChainDetails {
fn new(chain_id: ChainId, data: &Data) -> Self {
let Some(user_chain) = data.chains.get(chain_id) else {
panic!("Chain {chain_id} not found.");
};
ChainDetails {
is_default: Some(chain_id) == *data.default.read().unwrap(),
is_admin: chain_id == data.genesis_config.admin_chain_id(),
chain_id,
origin: data
.genesis_config
.chains
.iter()
.find(|description| description.id() == chain_id)
.map(ChainDescription::origin),
user_chain,
}
}
fn print_paragraph(&self) {
println!("-----------------------");
println!("{:<20} {}", "Chain ID:", self.chain_id);View on GitHub (pinned to 6c226ddcb3)
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
Example fix
# before # wallet JSON edited by hand: default_chain points to a removed chain linera wallet show # panics: Chain e5... not found. # after # re-add the missing chain (or fix the default chain id), then linera wallet show
Defensive patterns
Strategy: validation
Validate before calling
// Before displaying the wallet, check consistency:
for chain_id in [data.default.read().unwrap().expect("default chain"), admin_chain_id] {
assert!(data.chains.contains_key(&chain_id), "wallet missing entry for {chain_id}");
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- No chain ID specified and no default chain in wallet
- Wallet already exists: {}
- No default chain found for client
- nonexistent chain `{chain_id}`
- nonexistent chain `{chain_id}`
AI-assisted analysis of linera-io/linera-protocol@6c226ddcb3 (2026-08-22).
Data as JSON: /api/errors/555e18a91f610b52.
Report an issue: GitHub.