{"record":{"id":"9dbdd2a97e713054","repo":"nautechsystems/nautilus_trader","slug":"failed-to-fetch-cfm-balance-summary-e","errorCode":null,"errorMessage":"Failed to fetch CFM balance summary: {e}","messagePattern":"Failed to fetch CFM balance summary: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/coinbase/src/http/client.rs","lineNumber":1441,"sourceCode":"        };\n        self.inner\n            .cancel_orders(&request)\n            .await\n            .context(\"failed to cancel orders\")\n    }\n\n    /// Fetches the CFM (futures) balance summary.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error when the HTTP request fails or the response cannot be\n    /// deserialized.\n    pub async fn request_cfm_balance_summary(&self) -> anyhow::Result<CfmBalanceSummary> {\n        let response = self\n            .inner\n            .get_cfm_balance_summary()\n            .await\n            .map_err(|e| anyhow::anyhow!(\"Failed to fetch CFM balance summary: {e}\"))?;\n        Ok(response.balance_summary)\n    }\n\n    /// Fetches margin balances derived from the CFM balance summary.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error when the summary cannot be fetched or when a balance\n    /// cannot be constructed.\n    pub async fn request_cfm_margin_balances(&self) -> anyhow::Result<Vec<MarginBalance>> {\n        let summary = self.request_cfm_balance_summary().await?;\n        parse_cfm_margin_balances(&summary)\n    }\n\n    /// Fetches a margin [`AccountState`] derived from the CFM balance summary.\n    ///\n    /// # Errors\n    ///","sourceCodeStart":1423,"sourceCodeEnd":1459,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/coinbase/src/http/client.rs#L1423-L1459","documentation":"This error wraps any failure from the Coinbase `get_cfm_balance_summary` HTTP call in `request_cfm_balance_summary`. CFM is Coinbase Financial Markets (futures); the method fetches the futures balance summary and returns only its `balance_summary` field. The error means the HTTP request or API response failed — auth problems, missing futures entitlement, network issues, or API errors.","triggerScenarios":"Calling `request_cfm_balance_summary` when the CFM balance-summary endpoint returns an error: account not enabled for Coinbase futures, API keys lacking CFM scope, network failure, or non-success HTTP status.","commonSituations":"Pointing a spot-only Coinbase account at CFM reporting; using API keys created before futures access was granted; hitting the CFM endpoint from an unsupported region; generic network/auth outages during portfolio reconciliation.","solutions":["Inspect the wrapped inner error to identify auth vs entitlement vs network cause.","Confirm the Coinbase account is enrolled in Coinbase Financial Markets (futures).","Regenerate API keys with CFM/futures permissions and update credentials.","Verify regional availability of Coinbase futures for the account.","Retry transient failures with backoff."],"exampleFix":"// before: assumes CFM access always exists\nlet summary = client.request_cfm_balance_summary().await?;\n// after: degrade gracefully when CFM is not enabled\nlet summary = match client.request_cfm_balance_summary().await {\n    Ok(s) => Some(s),\n    Err(e) => {\n        tracing::warn!(\"CFM balance summary unavailable (futures not enabled?): {e}\");\n        None\n    }\n};","handlingStrategy":"try-catch","validationCode":"// Only call CFM endpoints when the account is futures-enabled\nif !account_config.cfm_enabled {\n    tracing::info!(\"skipping CFM balance summary: futures not enabled\");\n    return Ok(None);\n}","typeGuard":null,"tryCatchPattern":"match client.request_cfm_balance_summary().await {\n    Ok(summary) => handle(summary),\n    Err(e) if e.to_string().contains(\"401\") => refresh_credentials_and_retry().await?,\n    Err(e) => tracing::warn!(\"CFM balance summary failed: {e}\"),\n}","preventionTips":["Only enable CFM reporting when the account has futures access.","Keep API keys scoped and rotated with CFM permissions.","Separate futures failures from spot failures in reconciliation.","Log the inner error cause for diagnostics."],"tags":["network","http","coinbase","futures","cfm"],"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"}