nautechsystems/nautilus_trader · error · anyhow::Error

Persisted swap intent has no client order ID

Error message

Persisted swap intent has no client order ID

What it means

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.

Solutions

  1. Inspect the offending execution intent rows and delete or repair rows with NULL client_order_id.
  2. Re-run reconciliation after removing the corrupt rows so only well-formed intents are restored.
  3. Check schema migrations between adapter versions; apply pending migrations.
  4. If rows are from an older adapter version, follow the documented upgrade/migration path instead of manual SQL.

Example fix

// SQL repair before running reconcile
// before
SELECT * FROM execution_intents; -- rows with client_order_id NULL fail
// after
DELETE FROM execution_intents WHERE client_order_id IS NULL;
-- then: client.reconcile_unresolved_execution().await?;
Defensive patterns

Strategy: try-catch

Validate before calling

-- run before reconcile
SELECT id FROM execution_intents WHERE client_order_id IS NULL;
-- must return zero rows

Try / catch

match client.reconcile_unresolved_execution().await {
    Err(e) if e.to_string().contains("no client order ID") => {
        // purge corrupt rows, then retry
        purge_intents_with_null_order_ids(&db).await?;
        client.reconcile_unresolved_execution().await?
    }
    other => other,
}

Prevention

When it happens

Trigger: reconcile_unresolved_execution() or build_execution_verification_migration() encounters an ExecutionIntentRow whose client_order_id field is NULL in the database.

Common situations: 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.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/e83c817952f015ff. Report an issue: GitHub.

Appendix: source

Thrown at crates/adapters/blockchain/src/execution/client.rs:1026

            wallet_balance: Arc::clone(&self.wallet_balance),
            account_id: self.core.account_id,
            wallet_address: self.wallet_address,
            chain_id: self.chain.chain_id,
            max_fee_per_gas_wei: self.config.max_fee_per_gas_wei,
            base_fee_buffer_bps: self.config.base_fee_buffer_bps,
            gas_limit: self.config.gas_limit,
            gas_buffer_bps: self.config.gas_buffer_bps,
            receipt_timeout: receipt_timeout(self.transaction_limits.receipt_timeout_secs),
            receipt_max_polls: receipt_max_polls(self.transaction_limits.receipt_timeout_secs),
        })
    }

    fn restore_swap_plan(&self, intent: &ExecutionIntentRow) -> anyhow::Result<SwapPlan> {
        let client_order_id = ClientOrderId::new_checked(
            intent
                .client_order_id
                .as_deref()
                .ok_or_else(|| anyhow::anyhow!("Persisted swap intent has no client order ID"))?,
        )?;
        let order = self
            .core
            .cache()
            .try_order_owned(&client_order_id)
            .with_context(|| {
                format!(
                    "Cannot reconcile swap intent {} because order {client_order_id} is not restored",
                    intent.id
                )
            })?;
        let instrument_id = InstrumentId::from_str(
            intent
                .instrument_id
                .as_deref()
                .ok_or_else(|| anyhow::anyhow!("Persisted swap intent has no instrument ID"))?,
        )?;
        anyhow::ensure!(

View on GitHub (pinned to 18893faf8b)