{"record":{"id":"b584bebdf26e11f5","repo":"nautechsystems/nautilus_trader","slug":"asset-id-must-be-resolved-for-unsided-cancellation","errorCode":null,"errorMessage":"asset_id must be resolved for unsided cancellation","messagePattern":"asset_id must be resolved for unsided cancellation","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/polymarket/src/execution/cancellations.rs","lineNumber":361,"sourceCode":"            }\n        }\n\n        if side.is_some() && orders.is_empty() {\n            return Ok(());\n        }\n\n        let clock = self.clock;\n        let submitter = self.submitter.clone();\n        let emitter = self.emitter.clone();\n        let instrument_id = cmd.instrument_id;\n\n        let spawned = self.spawn_task(\"cancel_all_orders\", async move {\n            let _cancel_guard = cancel_guard;\n            let response = match side {\n                None => {\n                    let asset_id = asset_id\n                        .as_deref()\n                        .expect(\"asset_id must be resolved for unsided cancellation\");\n                    submitter.cancel_market_orders(asset_id).await\n                }\n                Some(_) => {\n                    let venue_order_ids = orders\n                        .iter()\n                        .map(|(venue_order_id, _)| venue_order_id.to_string())\n                        .collect::<Vec<_>>();\n\n                    let order_id_refs =\n                        venue_order_ids.iter().map(String::as_str).collect::<Vec<_>>();\n                    submitter.cancel_orders(&order_id_refs).await\n                }\n            };\n\n            match response {\n                Ok(response) => {\n                    for (venue_order_id, order) in &orders {\n                        let venue_order_id_str = venue_order_id.to_string();","sourceCodeStart":343,"sourceCodeEnd":379,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/polymarket/src/execution/cancellations.rs#L343-L379","documentation":"When cancel_all_orders is issued without a side, the Polymarket execution client must know which market (asset_id) to cancel for, since the venue API cancels per token/market. The code expects the asset_id to have been resolved from the command context; if it is None the panic fires.","triggerScenarios":"Submitting a CancelAllOrders command with side=None and no instrument_id/token resolvable to a Polymarket asset_id — e.g. a global cancel-all with no market context.","commonSituations":"Calling cancel_all_orders() without an instrument_id from a strategy running on multiple markets; UI/dashboard issuing a blanket 'flatten all' cancel; instrument_id not registered so asset_id lookup yielded None.","solutions":["Pass an instrument_id (or asset_id) to cancel_all_orders so the market can be resolved.","Iterate over open instruments and issue one unsided cancel per market instead of a global cancel.","If a side-specific cancel is acceptable, pass Some(side) so asset_id is not required."],"exampleFix":"// before\nexec_client.cancel_all_orders(None, None); // panics: no market context\n\n// after\nfor instrument_id in open_instrument_ids {\n    exec_client.cancel_all_orders(Some(instrument_id), None);\n}","handlingStrategy":"validation","validationCode":"# before calling the execution client\nif instrument_id is None and asset_id is None:\n    raise ValueError(\"cancel_all_orders requires an instrument_id/asset_id when side is None\")\nexec_client.cancel_all_orders(instrument_id, None)","typeGuard":null,"tryCatchPattern":"try:\n    exec_client.cancel_all_orders(instrument_id, None)\nexcept Exception as e:\n    self.log.error(f\"cancel-all failed for {instrument_id}: {e}\")","preventionTips":["Always scope cancel-all requests to a specific instrument/market.","Register instruments before issuing cancels so asset_id resolution succeeds.","For global flattening, loop per instrument rather than relying on one command."],"tags":["rust","panic","polymarket","orders","cancellation"],"backgroundTag":"missing-required-argument","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"}