{"record":{"id":"2dc12fdf66a2efba","repo":"nautechsystems/nautilus_trader","slug":"unmapped-in-scope-open-order-instrument-instrumen","errorCode":null,"errorMessage":"unmapped in-scope open order instrument {instrument_id} (token {order.asset_id}); {hint}","messagePattern":"unmapped in-scope open order instrument (.+?) \\(token (.+?)\\); (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/polymarket/src/execution/reconciliation.rs","lineNumber":641,"sourceCode":"        OrderEvidenceScope::Collection { instrument_filter } => match instruments\n            .get_cloned(&order.asset_id)\n        {\n            Some(instrument) => instrument,\n            None => {\n                let instrument_id =\n                    instrument_id_from_market_token(order.market.as_str(), order.asset_id.as_str());\n\n                if instrument_filter.is_some_and(|filter_id| {\n                    !polymarket_instrument_ids_equivalent(filter_id, instrument_id)\n                }) {\n                    return Ok(OrderRowResult {\n                        report: None,\n                        counted_filtered: false,\n                    });\n                }\n\n                if instrument_in_load_ids_scope(instrument_id, collection_load_ids) {\n                    anyhow::bail!(unmapped_in_scope_message(\n                        \"open order\",\n                        instrument_id,\n                        Some(&format!(\"token {}\", order.asset_id)),\n                        collection_load_ids,\n                    ));\n                }\n                log::debug!(\"Dropping out-of-scope unmapped open order instrument {instrument_id}\");\n                return Ok(OrderRowResult {\n                    report: None,\n                    counted_filtered: true,\n                });\n            }\n        },\n    };\n    let instrument_id = instrument.id();\n\n    if let OrderEvidenceScope::Collection {\n        instrument_filter: Some(filter_id),","sourceCodeStart":623,"sourceCodeEnd":659,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/polymarket/src/execution/reconciliation.rs#L623-L659","documentation":"While building an order status report during reconciliation, the instrument derived from the venue order (via its token asset_id) could not be mapped to a known instrument, and that instrument falls within the collection's load-ids scope. The adapter fails loudly rather than silently skipping an open order it should be able to report on.","triggerScenarios":"build_order_report_from_order (via build_target_order_report / build_order_reports_from_orders) encounters an in-scope open order whose token (order.asset_id) maps to an instrument_id absent from the loaded instrument set, as checked by instrument_in_load_ids_scope.","commonSituations":"Instrument configuration (load ids) not covering all tokens held by the account; a market was migrated or resolved and token ids changed; new positions opened in markets not listed in the adapter config; loading instruments with a filter that omits some CLOB tokens.","solutions":["Add the instrument for token {order.asset_id} to the adapter's configured instruments/load ids and reload instruments.","Call the instrument loading path (fetch_instruments / fetch_configured_instruments) covering the market matching the token before reconciling.","Check whether the token belongs to a stale/resolved market and update configuration accordingly.","If the order should genuinely be excluded, ensure it is filtered out before entering build_order_reports_from_orders so it is counted as filtered rather than hitting this bail."],"exampleFix":"// before: reconciling without loading the instrument for the order's token\nlet reports = exec.build_order_reports_from_orders(&orders)?;\n// after: load instruments covering the tokens first\nlet tokens: Vec<String> = orders.iter().map(|o| o.asset_id.clone()).collect();\nexec.ensure_instruments_loaded_for_tokens(&tokens)?;\nlet reports = exec.build_order_reports_from_orders(&orders)?;","handlingStrategy":"validation","validationCode":"// Rust: ensure every open order token maps to a loaded instrument before reconciling\nfn all_tokens_mapped(orders: &[OrderRow], instruments: &InstrumentMap) -> bool {\n    orders.iter().all(|o| instruments.contains_token(&o.asset_id))\n}\nassert!(all_tokens_mapped(&orders, &instruments), \"load missing instruments before reconcile\");","typeGuard":"fn mapped_instrument<'a>(instruments: &'a InstrumentMap, token: &str) -> Option<&'a Instrument> {\n    instruments.by_token(token)\n}","tryCatchPattern":null,"preventionTips":["Keep the configured instrument list in sync with every market the wallet can hold orders in.","Reload instruments after any market resolution/migration event.","Run a pre-reconciliation dry check mapping all order tokens to instruments."],"tags":["polymarket","reconciliation","instrument-mapping","rust"],"backgroundTag":"entity-not-found","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"}