{"record":{"id":"16385263dd3a6af8","repo":"nautechsystems/nautilus_trader","slug":"query-account-id-does-not-match-client-account","errorCode":null,"errorMessage":"Query account ID {} does not match client account ID {}","messagePattern":"Query account ID (.+?) does not match client account ID (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/execution/client.rs","lineNumber":5806,"sourceCode":"    }\n\n    fn cancel_all_orders(&self, cmd: CancelAllOrders) -> anyhow::Result<()> {\n        log::warn!(\n            \"Cancel-all for {} is not supported on the blockchain execution client\",\n            cmd.instrument_id\n        );\n        Ok(())\n    }\n\n    fn batch_cancel_orders(&self, cmd: BatchCancelOrders) -> anyhow::Result<()> {\n        for cancel in cmd.cancels {\n            self.cancel_order(cancel)?;\n        }\n        Ok(())\n    }\n\n    fn query_account(&self, cmd: QueryAccount) -> anyhow::Result<()> {\n        anyhow::ensure!(\n            cmd.account_id == self.core.account_id,\n            \"Query account ID {} does not match client account ID {}\",\n            cmd.account_id,\n            self.core.account_id\n        );\n        anyhow::ensure!(self.core.is_started(), \"Execution client is not started\");\n\n        let balances = self.wallet_balance.lock().as_account_balances()?;\n        self.generate_account_state(\n            balances,\n            vec![],\n            true,\n            get_atomic_clock_realtime().get_time_ns(),\n            None,\n        )\n    }\n\n    fn query_order(&self, cmd: QueryOrder) -> anyhow::Result<()> {","sourceCodeStart":5788,"sourceCodeEnd":5824,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/execution/client.rs#L5788-L5824","documentation":"The blockchain execution client is bound to a single account and only handles commands targeting that account. query_account validates that the incoming QueryAccount command's account_id matches the client's configured core.account_id before processing, throwing this error otherwise. It is a routing/safety check preventing cross-account balance reporting.","triggerScenarios":"Sending a QueryAccount command (via the message bus or direct handle) whose account_id differs from the account_id the execution client was configured/started with.","commonSituations":"Multiple trading accounts configured but commands fanned out to all clients; a copy-pasted account_id in config; a stale client instance still registered on the bus after an account switch; programmatic callers constructing QueryAccount with the wrong AccountId.","solutions":["Check the account_id in the failing QueryAccount command and correct it to match the client's configured account","Verify the execution client config (account/credentials) matches the account you intend to query","Re-register/restart the client so the message bus routes commands to the client bound to that account_id","If running multiple accounts, ensure each QueryAccount is delivered to the correct client instance"],"exampleFix":"// before\nlet cmd = QueryAccount::new(account_id: \"BK-001\");\nclient.query_account(cmd)?;\n// after\nlet cmd = QueryAccount::new(account_id: client.core.account_id);\nclient.query_account(cmd)?;","handlingStrategy":"validation","validationCode":"// before sending the command\nif cmd.account_id != client.account_id() {\n    return Err(anyhow::anyhow!(\"routing error: cmd {} vs client {}\", cmd.account_id, client.account_id()));\n}\nclient.query_account(cmd)?;","typeGuard":"fn targets_client(cmd: &QueryAccount, client: &ExecutionClient) -> bool {\n    cmd.account_id == client.core.account_id\n}","tryCatchPattern":"match client.query_account(cmd) {\n    Err(e) if e.to_string().contains(\"does not match client account ID\") => {\n        log::warn!(\"command routed to wrong client; re-dispatching by account_id\");\n        router.dispatch_by_account(cmd)?;\n    }\n    other => other,\n}","preventionTips":["Register exactly one execution client per account_id on the message bus","Validate account_id in config at startup (fail fast on mismatch)","Copy account ids from client config, not by hand","Log the client's bound account_id at startup for easy routing checks"],"tags":["account-id","validation","messaging"],"backgroundTag":"invalid-argument-value","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"}