{"record":{"id":"5d0d32a378577271","repo":"nautechsystems/nautilus_trader","slug":"persisted-swap-intent-has-no-instrument-id","errorCode":null,"errorMessage":"Persisted swap intent has no instrument ID","messagePattern":"Persisted swap intent has no instrument ID","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/execution/client.rs","lineNumber":1042,"sourceCode":"                .client_order_id\n                .as_deref()\n                .ok_or_else(|| anyhow::anyhow!(\"Persisted swap intent has no client order ID\"))?,\n        )?;\n        let order = self\n            .core\n            .cache()\n            .try_order_owned(&client_order_id)\n            .with_context(|| {\n                format!(\n                    \"Cannot reconcile swap intent {} because order {client_order_id} is not restored\",\n                    intent.id\n                )\n            })?;\n        let instrument_id = InstrumentId::from_str(\n            intent\n                .instrument_id\n                .as_deref()\n                .ok_or_else(|| anyhow::anyhow!(\"Persisted swap intent has no instrument ID\"))?,\n        )?;\n        anyhow::ensure!(\n            order.instrument_id() == instrument_id,\n            \"Persisted swap instrument {instrument_id} does not match restored order instrument {}\",\n            order.instrument_id()\n        );\n        anyhow::ensure!(\n            intent.trader_id.as_deref() == Some(order.trader_id().as_str()),\n            \"Persisted swap trader does not match restored order\"\n        );\n        anyhow::ensure!(\n            intent.strategy_id.as_deref() == Some(order.strategy_id().as_str()),\n            \"Persisted swap strategy does not match restored order\"\n        );\n        anyhow::ensure!(\n            intent.account_id.as_deref() == Some(self.core.account_id.as_str()),\n            \"Persisted swap account does not match execution client account\"\n        );","sourceCodeStart":1024,"sourceCodeEnd":1060,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/execution/client.rs#L1024-L1060","documentation":"restore_swap_plan() parses the intent row's instrument_id to validate it matches the restored cached order. If the column is NULL, InstrumentId::from_str cannot be called and the function raises this error — again indicating a malformed persisted execution intent.","triggerScenarios":"reconcile_unresolved_execution() or build_execution_verification_migration() processes an ExecutionIntentRow with a NULL instrument_id.","commonSituations":"Corrupted/partially written rows; schema drift from older adapter versions; manual database edits or restored backups missing columns.","solutions":["Delete or repair intent rows where instrument_id IS NULL.","Verify the cache database schema matches the current adapter version (run migrations).","Re-run reconciliation on the cleaned rows.","Restore the row data from a good backup if the values are unrecoverable."],"exampleFix":"// before\nSELECT * FROM execution_intents WHERE instrument_id IS NULL;\n// after\nDELETE FROM execution_intents WHERE instrument_id IS NULL;\nclient.reconcile_unresolved_execution().await?;","handlingStrategy":"try-catch","validationCode":"-- run before reconcile\nSELECT id FROM execution_intents WHERE instrument_id IS NULL;\n-- must return zero rows","typeGuard":null,"tryCatchPattern":"match client.reconcile_unresolved_execution().await {\n    Err(e) if e.to_string().contains(\"no instrument ID\") => {\n        purge_intents_with_null_instrument_ids(&db).await?;\n        client.reconcile_unresolved_execution().await?\n    }\n    other => other,\n}","preventionTips":["Check for NULL instrument_id rows before reconciliation.","Apply schema migrations when upgrading the adapter.","Avoid hand-editing cache tables; restore from backups instead."],"tags":["rust","postgres","data-corruption","instrument"],"backgroundTag":"null-argument","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}