{"record":{"id":"15505527c9cc7643","repo":"nautechsystems/nautilus_trader","slug":"no-wallet-balance-found-in-response","errorCode":null,"errorMessage":"No wallet balance found in response","messagePattern":"No wallet balance found in response","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/bybit/src/http/client.rs","lineNumber":4207,"sourceCode":"    pub async fn request_account_state(\n        &self,\n        account_type: BybitAccountType,\n        account_id: AccountId,\n    ) -> anyhow::Result<AccountState> {\n        let params = BybitWalletBalanceParams {\n            account_type,\n            coin: None,\n        };\n\n        let response = self.inner.get_wallet_balance(&params).await?;\n        let ts_init = self.generate_ts_init();\n\n        // Take the first wallet balance from the list\n        let wallet_balance = response\n            .result\n            .list\n            .first()\n            .ok_or_else(|| anyhow::anyhow!(\"No wallet balance found in response\"))?;\n\n        parse_account_state(wallet_balance, account_id, ts_init)\n    }\n\n    /// Request multiple order status reports.\n    ///\n    /// Orders for instruments not currently loaded in cache will be skipped.\n    ///\n    /// When `open_only` is true the realtime endpoint is queried for currently\n    /// open orders and again for recently closed orders, so terminal reports\n    /// are included. The closed pass fetches the most recent page only and is\n    /// not constrained by `start` or `end`.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if:\n    /// - Credentials are missing.\n    /// - The request fails.","sourceCodeStart":4189,"sourceCodeEnd":4225,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/bybit/src/http/client.rs#L4189-L4225","documentation":"The adapter expects Bybit's GET /v5/account/wallet-balance response to contain at least one wallet balance entry in `result.list`. When the list is empty, it cannot build an account state and throws this error.","triggerScenarios":"Calling request_account_state (wallet balance endpoint) when Bybit returns `result.list: []` — e.g. the account has no balance data for the queried account type (UNIFIED vs CONTRACT vs FUND mismatch).","commonSituations":"Querying a subaccount with no funds; passing the wrong accountType parameter; API key scoped to an account type with no balances; brand-new account before any deposit.","solutions":["Verify the account_type requested matches where funds actually live (UNIFIED, CONTRACT, FUND, SPOT)","Check the account has balance/deposit and the API key has Account read permission","Inspect the raw response `retCode`/`retMsg` for upstream errors masked as an empty list","Fund the account or switch to the correct account type in the adapter config"],"exampleFix":"// before\nlet wallet_balance = response.result.list.first()\n    .ok_or_else(|| anyhow::anyhow!(\"No wallet balance found in response\"))?;\n// after: validate the account type choice up front\nif response.result.list.is_empty() {\n    anyhow::bail!(\"No wallet balance for account_type={account_type}; check config and account funding\");\n}","handlingStrategy":"try-catch","validationCode":"if not response.get('result', {}).get('list'):\n    raise ValueError('wallet-balance returned empty list; check account_type')","typeGuard":null,"tryCatchPattern":"match client.request_account_state(...) { Err(e) if e.to_string().contains(\"No wallet balance\") => fallback_to_next_account_type(), other => other }","preventionTips":["Confirm the accountType (UNIFIED/CONTRACT/FUND/SPOT) matches where funds are held","Grant the API key Account read permission","Fund the account or test against an account with balances"],"tags":["rust","bybit","account-balance","empty-response"],"backgroundTag":"empty-result-set","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}