{"record":{"id":"e8ebdb66ade25ba3","repo":"linera-io/linera-protocol","slug":"no-non-admin-chain-specified-in-wallet-with-no-non","errorCode":null,"errorMessage":"No non-admin chain specified in wallet with no non-admin chain","messagePattern":"No non-admin chain specified in wallet with no non-admin chain","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"linera-client/src/client_context.rs","lineNumber":413,"sourceCode":"    pub fn default_chain(&self) -> ChainId {\n        self.default_chain\n            .expect(\"default chain requested but none set\")\n    }\n\n    /// Returns the lowest non-admin chain ID in the wallet.\n    pub async fn first_non_admin_chain(&self) -> Result<ChainId, Error> {\n        let admin_chain_id = self.admin_chain_id();\n        let chain_ids = self\n            .wallet()\n            .chain_ids()\n            .try_filter(|chain_id| futures::future::ready(*chain_id != admin_chain_id))\n            .try_collect::<Vec<ChainId>>()\n            .await\n            .map_err(Error::wallet)?;\n        Ok(chain_ids\n            .into_iter()\n            .min()\n            .expect(\"No non-admin chain specified in wallet with no non-admin chain\"))\n    }\n\n    /// Creates a node provider configured with this context's network options.\n    // TODO(#5084) this should match the `NodeProvider` from the `Environment`\n    pub fn make_node_provider(&self) -> NodeProvider {\n        NodeProvider::new(self.make_node_options())\n    }\n\n    fn make_node_options(&self) -> NodeOptions {\n        NodeOptions {\n            send_timeout: self.send_timeout,\n            recv_timeout: self.recv_timeout,\n            retry_delay: self.retry_delay,\n            max_retries: self.max_retries,\n            max_backoff: self.max_backoff,\n        }\n    }\n","sourceCodeStart":395,"sourceCodeEnd":431,"githubUrl":"https://github.com/linera-io/linera-protocol/blob/6c226ddcb332ef55118dc8d0aafbd093d5420899/linera-client/src/client_context.rs#L395-L431","documentation":"first_non_admin_chain (linera-client/src/client_context.rs:401) collects every wallet chain ID except the admin chain and takes .min() over the iterator. If the wallet contains only the admin chain (or nothing besides it), the iterator is empty, min() returns None, and expect panics. It is used by run to pick a chain to operate on, so startup of such commands aborts.","triggerScenarios":"Invoking a command whose run path calls first_non_admin_chain() while the wallet's chain_ids() yield only the admin chain. Typical with a newly generated devnet/test wallet before any user chain is created or claimed.","commonSituations":"Wallet generated with only the admin (root) chain; user chains were pruned from the wallet file; running faucet-less local setups where chains were expected to be auto-created but were not.","solutions":["Create or claim a non-admin chain into the wallet (faucet claim or wallet create with a new chain) and retry.","Verify wallet contents with linera wallet show to confirm at least one non-admin chain exists.","Use a wallet file that already includes user chains (point the command at the correct --wallet path)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"let chain_ids: Vec<ChainId> = wallet.chain_ids().try_collect().await?;\nlet non_admin: Vec<_> = chain_ids.into_iter().filter(|id| *id != admin_chain_id).collect();\nif non_admin.is_empty() {\n    anyhow::bail!(\"wallet has only the admin chain; create or claim a user chain first\");\n}\nlet chain = non_admin.into_iter().min().unwrap();","typeGuard":"fn has_non_admin_chain(chain_ids: &[ChainId], admin: ChainId) -> bool {\n    chain_ids.iter().any(|id| *id != admin)\n}","tryCatchPattern":"let result = std::panic::catch_unwind(AssertUnwindSafe(|| {\n    block_on(client_context.first_non_admin_chain())\n}));\nif let Err(_) = result {\n    // wallet unusable: guide user to claim a chain instead of retrying\n}","preventionTips":["Provision wallets with at least one user chain (faucet claim or wallet create) before automating commands.","In deployment scripts, run `linera wallet show` and assert a non-admin chain exists before start."],"tags":["linera-client","wallet","empty-collection","panic","rust"],"backgroundTag":"empty-collection-unwrap","analyzedSha":"6c226ddcb332ef55118dc8d0aafbd093d5420899","analyzedAt":"2026-08-22T22:49:09.787Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}