{"record":{"id":"1d8a96d7cf43353c","repo":"nautechsystems/nautilus_trader","slug":"failed-to-fetch-accounts-e","errorCode":null,"errorMessage":"Failed to fetch accounts: {e}","messagePattern":"Failed to fetch accounts: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/coinbase/src/http/client.rs","lineNumber":1124,"sourceCode":"    ///\n    /// Builds a cash-type [`AccountState`] from `/accounts` with one balance\n    /// per currency. Follows Coinbase's cursor pagination so multi-wallet\n    /// accounts are reported in full. `reported` is set to `true` since the\n    /// values come from the venue.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error when the HTTP request fails or the response cannot\n    /// be parsed.\n    pub async fn request_account_state(\n        &self,\n        account_id: AccountId,\n    ) -> anyhow::Result<AccountState> {\n        let accounts = self\n            .inner\n            .fetch_all_accounts()\n            .await\n            .map_err(|e| anyhow::anyhow!(\"Failed to fetch accounts: {e}\"))?;\n        let ts_event = self.ts_now();\n        parse_account_state(&accounts, account_id, true, ts_event, ts_event)\n    }\n\n    /// Requests a single order status report by venue or client order ID.\n    ///\n    /// Resolves venue order IDs first via `/orders/historical/{id}`. When only a\n    /// `client_order_id` is provided, paginates the order history filtered to\n    /// that client ID.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error when the HTTP request fails, the order cannot be found,\n    /// or the response cannot be parsed.\n    pub async fn request_order_status_report(\n        &self,\n        account_id: AccountId,\n        client_order_id: Option<ClientOrderId>,","sourceCodeStart":1106,"sourceCodeEnd":1142,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/coinbase/src/http/client.rs#L1106-L1142","documentation":"Raised by request_account_state when fetch_all_accounts() fails while building an AccountState from Coinbase /accounts. It aggregates paginated account fetching; any HTTP or pagination error aborts the account state request.","triggerScenarios":"Calling request_account_state(account_id) where the authenticated GET /accounts call fails: invalid or expired API key, missing required scopes, network error, or 4xx/5xx responses during pagination.","commonSituations":"API keys without the required accounts scope, rotated/expired Coinbase API secrets, clock skew breaking request signing, or connectivity problems on a trading server.","solutions":["Verify API key/secret are valid and have the 'view' (accounts) scope.","Check the wrapped {e}: retry 5xx/429 with backoff; fix auth for 401/403.","Ensure system clock is NTP-synced so request signatures validate.","Test the key with a direct curl to /api/v3/brokerage/accounts."],"exampleFix":"// before\nlet state = client.request_account_state(account_id).await?;\n// after (pre-check credentials)\nanyhow::ensure!(config.api_key.is_some() && config.api_secret.is_some(), \"Coinbase credentials missing\");\nlet state = client.request_account_state(account_id).await?;","handlingStrategy":"validation","validationCode":"anyhow::ensure!(config.api_key.is_some() && config.api_secret.is_some(), \"credentials required for /accounts\");\n// plus a startup curl to /api/v3/brokerage/accounts to confirm scopes","typeGuard":null,"tryCatchPattern":"match client.request_account_state(account_id).await {\n    Ok(s) => s,\n    Err(e) if e.to_string().contains(\"401\") => bail!(\"invalid/expired Coinbase credentials\"),\n    Err(e) => { retry_with_backoff(|| client.request_account_state(account_id)).await? }\n}","preventionTips":["Provision API keys with account-view scope and test them before trading.","Keep server clocks NTP-synced for request signing.","Rotate secrets through config/env without restarting mid-request."],"tags":["http","authentication","coinbase","account"],"backgroundTag":"http-error-response","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"}