{"record":{"id":"026d690c607c1d94","repo":"nautechsystems/nautilus_trader","slug":"active-execution-intent-has-no-nonce","errorCode":null,"errorMessage":"Active execution intent {} has no nonce","messagePattern":"Active execution intent (.+?) has no nonce","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/execution/client.rs","lineNumber":942,"sourceCode":"\n        if matches!(intent.status.as_str(), \"prepared\" | \"signed\") {\n            database\n                .mark_execution_intent_recoverable(intent.id)\n                .await?;\n            release_preparing_slot(&self.in_flight);\n            return Ok(());\n        }\n\n        let purpose = TransactionPurpose::parse(&intent.purpose).ok_or_else(|| {\n            anyhow::anyhow!(\n                \"Execution intent {} has unknown purpose {}\",\n                intent.id,\n                intent.purpose\n            )\n        })?;\n        let nonce = intent\n            .nonce\n            .ok_or_else(|| anyhow::anyhow!(\"Active execution intent {} has no nonce\", intent.id))?;\n        let hashes = database.get_execution_transaction_hashes(intent.id).await?;\n        let current = current_execution_hash(intent.id, &hashes)?;\n        let tx_hash = B256::from_str(&current.transaction_hash).with_context(|| {\n            format!(\n                \"Execution intent {} has invalid transaction hash {}\",\n                intent.id, current.transaction_hash\n            )\n        })?;\n        *self.in_flight.lock().expect(\"in-flight mutex poisoned\") =\n            Some(InFlightSlot::AwaitingFinality(InFlightTransaction {\n                intent_id: intent.id,\n                nonce,\n                tx_hash,\n                purpose,\n            }));\n\n        let plan = if purpose == TransactionPurpose::Swap {\n            Some(self.restore_swap_plan(&intent)?)","sourceCodeStart":924,"sourceCodeEnd":960,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/2114cf6f761429e0adb5ca9596fcd7b895b16011/crates/adapters/blockchain/src/execution/client.rs#L924-L960","documentation":"An active execution_intent row has nonce = NULL when reconciliation needs it to track the in-flight transaction. The nonce is assigned by assign_execution_intent_nonce() during prepare_and_sign, before signing; an active intent that reached broadcast/pending status must therefore always carry one. NULL means the intent was persisted but the nonce-assignment write never committed, or the row was changed outside the client.","triggerScenarios":"reconcile_unresolved_execution() loads an active intent (active = TRUE) whose status is past prepared/signed (e.g. 'pending' or 'included') and whose nonce column is NULL: a partially written row from a crashed run between INSERT and nonce assignment, manual row edits, or a database restored inconsistently.","commonSituations":"Process killed or Postgres failover exactly between intent insert and nonce assignment; DBA manually resetting intents; a store shared between two wallet configurations where one tool wrote incomplete rows.","solutions":["Inspect the row: SELECT id, status, nonce FROM execution_intent WHERE active AND nonce IS NULL;","If status is 'prepared' or 'signed', the reconciler would have handled it, so for NULL-nonce rows past those statuses the row is invalid: verify on-chain (eth_getTransactionByHash of its current hash) whether anything was broadcast","If nothing was broadcast, mark the intent inactive (active = FALSE) so startup proceeds, and let the slot logic re-claim cleanly","If a transaction did land, repair the nonce from the on-chain transaction and let reconciliation finish"],"exampleFix":"-- before: active intent without nonce blocks connect()\nSELECT id, status, nonce FROM execution_intent WHERE active AND nonce IS NULL;\n\n-- after: confirm no on-chain tx, then retire the malformed intent\nUPDATE execution_intent SET active = FALSE WHERE id = 42 AND nonce IS NULL;","handlingStrategy":"validation","validationCode":"-- Active intents past the signed stage must carry a nonce\nSELECT id, status, nonce\nFROM execution_intent\nWHERE active\n  AND nonce IS NULL\n  AND status NOT IN ('prepared', 'signed');\n-- Zero rows expected; otherwise reconcile or retire the row before connect().","typeGuard":null,"tryCatchPattern":"try:\n    client.connect()\nexcept Exception as e:\n    if 'has no nonce' in str(e):\n        # check execution_transaction_hash + on-chain state, then repair or deactivate the intent\n        ...\n    raise","preventionTips":["Let the client own nonce assignment; never reset nonces or intent rows while a trader is running","After a crash, reconnect the same wallet+store so reconciliation completes partial writes"],"tags":["blockchain","reconciliation","nonce","postgres","data-integrity"],"backgroundTag":"data-integrity-violation","analyzedSha":"2114cf6f761429e0adb5ca9596fcd7b895b16011","analyzedAt":"2026-08-21T11:28:30.864Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}