{"record":{"id":"aa9dfdaf4ed26133","repo":"nautechsystems/nautilus_trader","slug":"serde-json-deserialization-error-e","errorCode":null,"errorMessage":"serde_json deserialization error: {e}","messagePattern":"serde_json deserialization error: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/coinbase/src/http/client.rs","lineNumber":1177,"sourceCode":"                    .into_iter()\n                    .next()\n                    .ok_or_else(|| anyhow::anyhow!(\"No order found for client_order_id={cid}\"))?;\n                let instrument = self.get_or_fetch_instrument(order.product_id).await?;\n                let ts_init = self.ts_now();\n                return parse_order_status_report(&order, &instrument, account_id, ts_init);\n            }\n            (None, None) => {\n                anyhow::bail!(\"Either client_order_id or venue_order_id is required\")\n            }\n        };\n\n        let json = self\n            .inner\n            .get_order(venue_order_id.as_str())\n            .await\n            .map_err(|e| anyhow::anyhow!(\"Failed to fetch order: {e}\"))?;\n        let response: OrderResponse =\n            serde_json::from_value(json).map_err(|e| anyhow::anyhow!(e))?;\n        let instrument = self\n            .get_or_fetch_instrument(response.order.product_id)\n            .await?;\n        let ts_init = self.ts_now();\n        parse_order_status_report(&response.order, &instrument, account_id, ts_init)\n    }\n\n    /// Requests order status reports, optionally filtered by instrument, open\n    /// status, and time window.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error when the HTTP request fails or when any response cannot\n    /// be deserialized.\n    pub async fn request_order_status_reports(\n        &self,\n        account_id: AccountId,\n        instrument_id: Option<InstrumentId>,","sourceCodeStart":1159,"sourceCodeEnd":1195,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/coinbase/src/http/client.rs#L1159-L1195","documentation":"This error is raised when the JSON returned by Coinbase's `get_order` endpoint cannot be deserialized into the adapter's `OrderResponse` struct via `serde_json::from_value`. It means the response payload shape did not match the expected schema — Coinbase may have changed its API response, or an error/empty body reached deserialization. The adapter throws it because it cannot construct an `OrderStatusReport` from an unrecognized payload.","triggerScenarios":"Calling `request_order_status_report` when Coinbase returns order JSON missing or with differently-typed fields than `OrderResponse` expects (null in a required field, new nested structure after a Coinbase API version bump, or an error body shaped as valid JSON).","commonSituations":"Coinbase Advanced Trade API schema updates breaking an outdated adapter version; querying an order whose state produces unexpected null fields; error responses that pass the HTTP layer but fail `from_value`.","solutions":["Read the serde error in the message chain to identify which field failed (missing, type mismatch, null).","Upgrade the coinbase adapter / NautilusTrader to a version matching the current Coinbase API schema.","Log the offending JSON on failure and compare against the expected `OrderResponse` schema.","Check whether the venue_order_id points at a deleted/legacy order returning an unusual payload.","If persistent, pin against the Coinbase API version the adapter was built for or file an adapter issue."],"exampleFix":"// before: opaque failure with no payload context\nlet response: OrderResponse = serde_json::from_value(json).map_err(|e| anyhow::anyhow!(e))?;\n// after: capture payload for diagnosis\nlet response: OrderResponse = serde_json::from_value(json.clone())\n    .map_err(|e| anyhow::anyhow!(\"order deserialization failed: {e}; payload={json}\"))?;","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"fn is_valid_order_json(v: &serde_json::Value) -> bool {\n    v.get(\"order\")\n        .and_then(|o| o.get(\"product_id\"))\n        .and_then(|p| p.as_str())\n        .is_some()\n}","tryCatchPattern":"let response: OrderResponse = serde_json::from_value(json.clone()).map_err(|e| {\n    tracing::error!(\"OrderResponse deserialize failed: {e}; payload={json}\");\n    anyhow::anyhow!(e)\n})?;","preventionTips":["Keep the adapter in sync with Coinbase API changelogs.","Log the raw JSON payload on deserialization failure.","Use serde default/Option for fields Coinbase may omit.","Add unit tests deserializing captured live payloads."],"tags":["serde","deserialization","json","coinbase"],"backgroundTag":"json-unmarshal-failed","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"}