nautechsystems/nautilus_trader · error · anyhow::Error

Persisted swap intent has no instrument ID

Error message

Persisted swap intent has no instrument ID

What it means

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.

Solutions

  1. Delete or repair intent rows where instrument_id IS NULL.
  2. Verify the cache database schema matches the current adapter version (run migrations).
  3. Re-run reconciliation on the cleaned rows.
  4. Restore the row data from a good backup if the values are unrecoverable.

Example fix

// before
SELECT * FROM execution_intents WHERE instrument_id IS NULL;
// after
DELETE FROM execution_intents WHERE instrument_id IS NULL;
client.reconcile_unresolved_execution().await?;
Defensive patterns

Strategy: try-catch

Validate before calling

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

Try / catch

match client.reconcile_unresolved_execution().await {
    Err(e) if e.to_string().contains("no instrument ID") => {
        purge_intents_with_null_instrument_ids(&db).await?;
        client.reconcile_unresolved_execution().await?
    }
    other => other,
}

Prevention

When it happens

Trigger: reconcile_unresolved_execution() or build_execution_verification_migration() processes an ExecutionIntentRow with a NULL instrument_id.

Common situations: Corrupted/partially written rows; schema drift from older adapter versions; manual database edits or restored backups missing columns.

Related errors


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

Appendix: source

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

                .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!(
            order.instrument_id() == instrument_id,
            "Persisted swap instrument {instrument_id} does not match restored order instrument {}",
            order.instrument_id()
        );
        anyhow::ensure!(
            intent.trader_id.as_deref() == Some(order.trader_id().as_str()),
            "Persisted swap trader does not match restored order"
        );
        anyhow::ensure!(
            intent.strategy_id.as_deref() == Some(order.strategy_id().as_str()),
            "Persisted swap strategy does not match restored order"
        );
        anyhow::ensure!(
            intent.account_id.as_deref() == Some(self.core.account_id.as_str()),
            "Persisted swap account does not match execution client account"
        );

View on GitHub (pinned to 18893faf8b)