{"record":{"id":"103b538f0203670f","repo":"nautechsystems/nautilus_trader","slug":"client-order-client-order-id-is-registered-to-ve","errorCode":null,"errorMessage":"client order {client_order_id} is registered to venue order {registered_venue_order_id}, not requested venue order {venue_order_id}","messagePattern":"client order (.+?) is registered to venue order (.+?), not requested venue order (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/polymarket/src/execution/reports.rs","lineNumber":130,"sourceCode":"        ]\n        .into_iter()\n        .flatten()\n        {\n            if let Some(known) = client_order_id {\n                anyhow::ensure!(\n                    candidate == known,\n                    \"venue order {venue_order_id} has contradictory client associations {known} and {candidate}\",\n                );\n            } else {\n                client_order_id = Some(candidate);\n            }\n        }\n\n        if let Some(client_order_id) = client_order_id\n            && let Some(registered_venue_order_id) =\n                self.order_contexts.venue_order_id(&client_order_id)\n        {\n            anyhow::ensure!(\n                registered_venue_order_id == venue_order_id,\n                \"client order {client_order_id} is registered to venue order {registered_venue_order_id}, not requested venue order {venue_order_id}\",\n            );\n        }\n\n        let cached_order = client_order_id.and_then(|value| self.core.cache().order_owned(&value));\n        if let Some(cached_order) = cached_order.as_ref() {\n            let cached_venue_order_id = cached_order.venue_order_id();\n            if let Some(cached_venue_order_id) = cached_venue_order_id {\n                anyhow::ensure!(\n                    cached_venue_order_id == venue_order_id,\n                    \"cached client order {} is associated with venue order {cached_venue_order_id}, not requested venue order {venue_order_id}\",\n                    cached_order.client_order_id(),\n                );\n            } else {\n                anyhow::ensure!(\n                    cached_client_order_id == client_order_id\n                        || self","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/polymarket/src/execution/reports.rs#L112-L148","documentation":"This error is thrown by resolve_target_order_authority in the Polymarket execution report generator when a client_order_id is supplied and the adapter's order_contexts registry maps that client order id to a different venue order id than the one requested. It is a consistency guard ensuring the caller does not query or generate reports for a venue order that is not the one registered under the given client order id. The adapter refuses to proceed rather than returning a report for the wrong venue order.","triggerScenarios":"Calling query_order_command, generate_order_status_report_impl, or generate_fill_reports_impl with a (client_order_id, venue_order_id) pair whose mapping in order_contexts does not match — e.g. passing a stale or swapped id after a modify/replace assigned a new venue order id.","commonSituations":"Reusing an old client_order_id after an order amendment created a new venue order id; copy-paste mixing ids between orders; bot logic caching ids from a previous session while the adapter registry was rebuilt.","solutions":["Verify the client_order_id/venue_order_id pair with self.order_contexts.venue_order_id(&client_order_id) before calling","Fetch the correct venue order id registered for the client order id and use that instead","If the order was replaced, query using the current (new) venue order id","Clear stale id caches in the calling strategy and re-derive ids from the cache"],"exampleFix":"// before\nlet report = exec_client.generate_order_status_report(client_order_id, stale_venue_order_id).await?;\n// after\nlet venue_order_id = order_contexts.venue_order_id(&client_order_id)\n    .context(\"no venue order registered for client order\")?;\nlet report = exec_client.generate_order_status_report(Some(client_order_id), venue_order_id).await?;","handlingStrategy":"validation","validationCode":"let registered = order_contexts.venue_order_id(&client_order_id);\nanyhow::ensure!(registered == Some(venue_order_id), \"id pair mismatch: {:?} vs {}\", registered, venue_order_id);","typeGuard":"fn is_registered_pair(ctxs: &OrderContexts, coid: ClientOrderId, void_id: VenueOrderId) -> bool {\n    ctxs.venue_order_id(&coid).as_ref() == Some(&void_id)\n}","tryCatchPattern":"match client.generate_order_status_report(Some(coid), void_id).await {\n    Ok(r) => r,\n    Err(e) if e.to_string().contains(\"is registered to venue order\") => {\n        // re-derive void_id from registry and retry once\n        ...\n    }\n}","preventionTips":["Always derive venue_order_id from order_contexts or the cached order, never from strategy-side stale state","Track replace operations: after modification, update all stored id references","Log both ids before querying so mismatches are diagnosable"],"tags":["rust","order-management","adapter","polymarket","id-mismatch"],"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"}