{"record":{"id":"e83c817952f015ff","repo":"nautechsystems/nautilus_trader","slug":"persisted-swap-intent-has-no-client-order-id","errorCode":null,"errorMessage":"Persisted swap intent has no client order ID","messagePattern":"Persisted swap intent has no client order ID","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/execution/client.rs","lineNumber":1026,"sourceCode":"            wallet_balance: Arc::clone(&self.wallet_balance),\n            account_id: self.core.account_id,\n            wallet_address: self.wallet_address,\n            chain_id: self.chain.chain_id,\n            max_fee_per_gas_wei: self.config.max_fee_per_gas_wei,\n            base_fee_buffer_bps: self.config.base_fee_buffer_bps,\n            gas_limit: self.config.gas_limit,\n            gas_buffer_bps: self.config.gas_buffer_bps,\n            receipt_timeout: receipt_timeout(self.transaction_limits.receipt_timeout_secs),\n            receipt_max_polls: receipt_max_polls(self.transaction_limits.receipt_timeout_secs),\n        })\n    }\n\n    fn restore_swap_plan(&self, intent: &ExecutionIntentRow) -> anyhow::Result<SwapPlan> {\n        let client_order_id = ClientOrderId::new_checked(\n            intent\n                .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!(","sourceCodeStart":1008,"sourceCodeEnd":1044,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/execution/client.rs#L1008-L1044","documentation":"restore_swap_plan() rebuilds a SwapPlan from a persisted ExecutionIntentRow. The row's client_order_id column is Option<String>; if it is NULL the ClientOrderId needed to fetch the cached order cannot be constructed, so the function fails. This represents a corrupted or externally written intent row.","triggerScenarios":"reconcile_unresolved_execution() or build_execution_verification_migration() encounters an ExecutionIntentRow whose client_order_id field is NULL in the database.","commonSituations":"Rows written by an older schema version or a manual insert; a migration bug that dropped the column; partial write from a crash between row creation and order ID assignment.","solutions":["Inspect the offending execution intent rows and delete or repair rows with NULL client_order_id.","Re-run reconciliation after removing the corrupt rows so only well-formed intents are restored.","Check schema migrations between adapter versions; apply pending migrations.","If rows are from an older adapter version, follow the documented upgrade/migration path instead of manual SQL."],"exampleFix":"// SQL repair before running reconcile\n// before\nSELECT * FROM execution_intents; -- rows with client_order_id NULL fail\n// after\nDELETE FROM execution_intents WHERE client_order_id IS NULL;\n-- then: client.reconcile_unresolved_execution().await?;","handlingStrategy":"try-catch","validationCode":"-- run before reconcile\nSELECT id FROM execution_intents WHERE client_order_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 client order ID\") => {\n        // purge corrupt rows, then retry\n        purge_intents_with_null_order_ids(&db).await?;\n        client.reconcile_unresolved_execution().await?\n    }\n    other => other,\n}","preventionTips":["Run a pre-flight SQL check for NULL intent columns before reconciliation.","Never insert execution intent rows manually.","Keep cache schema migrations up to date with adapter versions."],"tags":["rust","postgres","data-corruption","reconciliation"],"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"}