{"record":{"id":"aa131d40b65490f6","repo":"nautechsystems/nautilus_trader","slug":"response-missing-both-result-and-error-fields","errorCode":null,"errorMessage":"Response missing both result and error fields","messagePattern":"Response missing both result and error fields","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/rpc/http.rs","lineNumber":182,"sourceCode":"                let preview = rpc_response_preview(&raw_response);\n                anyhow::anyhow!(\"Failed to parse eth call response: {e}\\nRaw response: {preview}\")\n            })?;\n\n        // Check for non-standard rate limit error (e.g., Infura)\n        // These responses have code/message at top level without jsonrpc field\n        if parsed.jsonrpc.is_none()\n            && let (Some(code), Some(message)) = (parsed.code, parsed.message)\n        {\n            anyhow::bail!(\"RPC provider error {code}: {message}\");\n        }\n\n        if let Some(error) = parsed.error {\n            anyhow::bail!(\"RPC error {}: {}\", error.code, error.message);\n        }\n\n        parsed\n            .result\n            .ok_or_else(|| anyhow::anyhow!(\"Response missing both result and error fields\"))\n    }\n\n    /// Creates a properly formatted `eth_call` JSON-RPC request object targeting a specific contract address with encoded function data.\n    #[must_use]\n    pub fn construct_eth_call(\n        &self,\n        to: &str,\n        call_data: &[u8],\n        block: Option<u64>,\n    ) -> serde_json::Value {\n        self.construct_eth_call_request(None, to, call_data, block)\n    }\n\n    fn construct_eth_call_request(\n        &self,\n        from: Option<&Address>,\n        to: &str,\n        call_data: &[u8],","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/rpc/http.rs#L164-L200","documentation":"execute_rpc_call_with_timeout expects every JSON-RPC response to carry either a result or an error field. If RpcNodeHttpResponse has neither, the node returned a structurally valid but semantically empty response, and the code fails with this error rather than returning None. This indicates a non-conforming or buggy RPC endpoint.","triggerScenarios":"Calling execute_rpc_call or get_balance_with_timeout against a node that returns a JSON object without both 'result' and 'error' — e.g. a partially standard-compliant proxy, a load balancer health response, or a non-standard rate-limit body that also lacked top-level code/message.","commonSituations":"Routing through API gateways that intercept and return custom JSON envelopes; misconfigured reverse proxies in front of the node; provider returning unusual shaped errors that evade both the error branch and the Infura-style rate-limit check.","solutions":["Log the raw response body for this case to see what the node actually returned.","Point the client directly at a standard JSON-RPC node, bypassing any gateway/proxy layer.","If the provider legitimately returns this shape, pre-validate with a simple request (eth_chainId) and switch providers if non-conformant.","Update to a newer version of the client, which may handle additional non-standard response shapes."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// health-check the provider conforms to JSON-RPC at startup\nlet v: serde_json::Value = post_json(rpc_url, eth_chain_id_request()).await?;\nif v.get(\"result\").is_none() && v.get(\"error\").is_none() {\n    return Err(\"provider returns non-conformant JSON-RPC responses\".into());\n}","typeGuard":null,"tryCatchPattern":"match execute_rpc_call(&client, req).await {\n    Ok(v) => Ok(v),\n    Err(e) if e.to_string().contains(\"Response missing both result and error fields\") => {\n        // non-conformant endpoint: log raw body and failover\n        tracing::error!(\"non-conformant RPC response; switching provider\");\n        switch_to_backup_provider().await\n    }\n    Err(e) => Err(e),\n}","preventionTips":["Run a JSON-RPC conformance probe (eth_chainId) when adding a new provider.","Bypass API gateways/proxies that rewrite JSON-RPC envelopes.","Keep the client updated to handle known non-standard provider shapes.","Failover automatically when a provider repeatedly returns empty envelopes."],"tags":["rpc","json-rpc","unexpected-response","http"],"backgroundTag":"unexpected-response-shape","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}