{"record":{"id":"3584147eba8009a3","repo":"nautechsystems/nautilus_trader","slug":"registered-order-instrument-does-not-match-requ","errorCode":null,"errorMessage":"registered order instrument {} does not match requested instrument {requested_instrument_id}","messagePattern":"registered order instrument (.+?) does not match requested instrument (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/polymarket/src/execution/reports.rs","lineNumber":168,"sourceCode":"                            .venue_order_id(&cached_order.client_order_id())\n                            == Some(venue_order_id),\n                    \"cached client order {} has no association with requested venue order {venue_order_id}\",\n                    cached_order.client_order_id(),\n                );\n            }\n\n            if let Some(requested_instrument_id) = requested_instrument_id {\n                anyhow::ensure!(\n                    cached_order.instrument_id() == requested_instrument_id,\n                    \"cached order instrument {} does not match requested instrument {requested_instrument_id}\",\n                    cached_order.instrument_id(),\n                );\n            }\n        }\n\n        if let Some(context) = context {\n            if let Some(requested_instrument_id) = requested_instrument_id {\n                anyhow::ensure!(\n                    context.identity.instrument_id == requested_instrument_id,\n                    \"registered order instrument {} does not match requested instrument {requested_instrument_id}\",\n                    context.identity.instrument_id,\n                );\n            }\n\n            if let Some(cached_order) = cached_order.as_ref() {\n                anyhow::ensure!(\n                    context.identity.client_order_id == cached_order.client_order_id()\n                        && context.identity.instrument_id == cached_order.instrument_id()\n                        && context.identity.order_side == cached_order.order_side()\n                        && context.identity.order_type == cached_order.order_type()\n                        && context.time_in_force == cached_order.time_in_force(),\n                    \"registered order context for {venue_order_id} contradicts cached order {}\",\n                    cached_order.client_order_id(),\n                );\n            }\n        }","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/polymarket/src/execution/reports.rs#L150-L186","documentation":"When a registered order context exists for the target venue order, its identity.instrument_id must match the requested instrument_id. This ensure! fires when the context registered in order_contexts belongs to a different market than requested. Like the cached-order instrument check, it guards against cross-market report generation.","triggerScenarios":"generate_order_status_report_impl or generate_fill_reports_impl with requested_instrument_id that differs from the instrument stored in the order context registered under venue_order_id.","commonSituations":"Passing a default/hardcoded instrument id for all queries in a multi-instrument strategy; instrument id changed between submit and query (wrong token id / condition id).","solutions":["Pass the instrument id from the registered context (context.identity.instrument_id)","Omit requested_instrument_id so the check is skipped","Fix instrument id construction to use the same source used at order submission"],"exampleFix":"// before\nlet report = client.generate_order_status_report(None, void_id, Some(default_instrument)).await?;\n// after\nlet instrument_id = order_contexts.get(&void_id).map(|c| c.identity.instrument_id);\nlet report = client.generate_order_status_report(None, void_id, instrument_id).await?;","handlingStrategy":"validation","validationCode":"if let Some(ctx) = order_contexts.get(&venue_order_id) {\n    anyhow::ensure!(ctx.identity.instrument_id == instrument_id, \"registered context instrument mismatch\");\n}","typeGuard":"fn context_instrument(ctxs: &OrderContexts, void_id: &VenueOrderId, iid: &InstrumentId) -> bool {\n    ctxs.get(void_id).map(|c| c.identity.instrument_id == *iid).unwrap_or(false)\n}","tryCatchPattern":"match client.generate_fill_reports_impl(None, void_id, Some(iid)).await {\n    Err(e) if e.to_string().contains(\"registered order instrument\") => retry_with_registered_instrument(),\n    other => other?,\n}","preventionTips":["Never hardcode a default instrument id for queries in multi-market code","Derive the instrument id from the registered context rather than call-site assumptions","Validate instrument id normalization once at adapter startup"],"tags":["rust","instrument-id","validation","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-14T00:17:10.932Z"}