{"record":{"id":"ebdc1769b6c468e6","repo":"linera-io/linera-protocol","slug":"service-requires-a-default-chain-in-the-wallet","errorCode":null,"errorMessage":"Service requires a default chain in the wallet","messagePattern":"Service requires a default chain in the wallet","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"linera-service/src/cli/main.rs","lineNumber":1328,"sourceCode":"                #[cfg(with_metrics)]\n                metrics_port,\n                operator_application_ids,\n                operators,\n                controller_application_id,\n                task_retry_delay_secs,\n                read_only,\n                query_cache_size,\n                allowed_subscriptions,\n                subscription_ttls,\n                pause,\n            } => {\n                let context = options\n                    .create_client_context(storage, wallet, keystore)\n                    .await?;\n\n                let default_chain = context.wallet().default_chain();\n                let chain_id =\n                    default_chain.expect(\"Service requires a default chain in the wallet\");\n\n                assert!(\n                    operator_application_ids.is_empty() || controller_application_id.is_none(),\n                    \"Cannot run a static list of applications when a controller is given.\"\n                );\n\n                let cancellation_token = CancellationToken::new();\n                tokio::spawn(listen_for_shutdown_signals(cancellation_token.clone()));\n\n                let operators: BTreeMap<String, PathBuf> = operators.into_iter().collect();\n                for (name, path) in &operators {\n                    info!(\"Operator '{}' -> {}\", name, path.display());\n                }\n                let operators = Arc::new(operators);\n\n                // Start the task processor if operator applications are specified.\n                let retry_delay = TimeDelta::from_secs(task_retry_delay_secs);\n","sourceCodeStart":1310,"sourceCodeEnd":1346,"githubUrl":"https://github.com/linera-io/linera-protocol/blob/6c226ddcb332ef55118dc8d0aafbd093d5420899/linera-service/src/cli/main.rs#L1310-L1346","documentation":"The `linera service` node command resolves the hosting chain from the wallet's default chain and panics with 'Service requires a default chain in the wallet' when default_chain() returns None. Unlike query-application, this command has no --chain-id override, so the default chain is mandatory.","triggerScenarios":"Starting `linera service` with a wallet that has no default chain: brand-new wallet file, wallet where all chains were forgotten, or a wallet assembled by importing keys without assigning a chain as default.","commonSituations":"Running the GraphQL/node service in a container or CI with a fresh wallet that was never initialized with a chain; after `linera wallet forget-keys` removed the last chain; mismatched LINERA_WALLET_HOME pointing at an empty wallet.","solutions":["Run `linera wallet set-default <chain_id>` with an existing chain before starting the service","If the wallet has no chains yet, initialize it and create/assign a chain first (`linera wallet init`, then create-own-chain or assign)","Verify LINERA_WALLET_HOME / --wallet points at the wallet you actually use for applications","Bake the set-default step into the service startup script so environment resets cannot reproduce the panic"],"exampleFix":"# before\nlinera service --port 8080   # panics: no default chain\n\n# after\nlinera wallet set-default 4ee5..c0de\nlinera service --port 8080","handlingStrategy":"validation","validationCode":"# Pre-flight for the service command (which has no --chain-id override).\nlinera wallet --help >/dev/null\nDEFAULT=$(jq -r '.default_chain // empty' \"$LINERA_WALLET_HOME/wallet.json\" 2>/dev/null)\n[ -n \"$DEFAULT\" ] || { echo 'set a default chain first: linera wallet set-default <chain_id>' >&2; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Make `linera wallet set-default` the first step of every service deployment runbook","Verify LINERA_WALLET_HOME points to the wallet holding your applications before starting the service","Add a container healthcheck/prestart that asserts a default chain exists"],"tags":["linera","cli","service","wallet","default-chain"],"backgroundTag":"missing-default-chain","analyzedSha":"6c226ddcb332ef55118dc8d0aafbd093d5420899","analyzedAt":"2026-08-22T22:49:09.787Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}