{"record":{"id":"ca6b3a33baa03402","repo":"nautechsystems/nautilus_trader","slug":"execution-intent-has-unknown-purpose","errorCode":null,"errorMessage":"Execution intent {} has unknown purpose {}","messagePattern":"Execution intent (.+?) has unknown purpose (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/execution/client.rs","lineNumber":934,"sourceCode":"            return Ok(());\n        };\n        anyhow::ensure!(\n            intent.schema_version == crate::execution::transaction::EXECUTION_SCHEMA_VERSION,\n            \"Execution intent {} uses unsupported schema version {}\",\n            intent.id,\n            intent.schema_version\n        );\n\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 {","sourceCodeStart":916,"sourceCodeEnd":952,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/2114cf6f761429e0adb5ca9596fcd7b895b16011/crates/adapters/blockchain/src/execution/client.rs#L916-L952","documentation":"During startup reconciliation, TransactionPurpose::parse() returned None for the intent's persisted purpose column. The parser only accepts the exact strings \"wrap\", \"approve\", and \"swap\" (WETH deposit, ERC-20 approve, Uniswap V3 exactInputSingle). Any other value means the row cannot be mapped to a known replay strategy, so reconciliation aborts.","triggerScenarios":"An active execution_intent row whose purpose is not exactly 'wrap', 'approve', or 'swap': manually edited rows, a newer binary that persisted an additional purpose enum variant, or data written into the table by another tool.","commonSituations":"Hand-fixing rows in Postgres during incident response; running a newer adapter version against a store read by an older one; typos introduced by ETL jobs touching the execution_intent table.","solutions":["Inspect the row: SELECT id, purpose, status FROM execution_intent WHERE active AND purpose NOT IN ('wrap','approve','swap');","If the intent is genuinely one of the known purposes, correct the string (lowercase, no whitespace)","If it was written by a newer version, reconcile with that version or archive the row (set active = FALSE) after confirming no funds are at risk","Restrict write access to the execution tables so only the NautilusTrader process mutates them"],"exampleFix":"-- before\nSELECT id, purpose FROM execution_intent WHERE active;\n-- purpose = 'Swap ' (trailing space, parse fails)\n\n-- after\nUPDATE execution_intent SET purpose = 'swap' WHERE id = 42;","handlingStrategy":"validation","validationCode":"-- Verify persisted purposes are parseable before startup\nSELECT id, purpose\nFROM execution_intent\nWHERE active\n  AND purpose NOT IN ('wrap', 'approve', 'swap');\n-- Expect zero rows before calling connect().","typeGuard":"def is_known_purpose(value: str) -> bool:\n    return value in ('wrap', 'approve', 'swap')","tryCatchPattern":"try:\n    client.connect()\nexcept Exception as e:\n    if 'unknown purpose' in str(e):\n        # inspect/repair execution_intent.purpose, then retry connect\n        ...\n    raise","preventionTips":["Never hand-edit purpose strings in the execution_intent table; if you must, keep to lowercase wrap/approve/swap","Reconcile pending intents with the same binary version that created them before switching versions"],"tags":["blockchain","reconciliation","enum-parsing","postgres","data-integrity"],"backgroundTag":"unknown-enum-value","analyzedSha":"2114cf6f761429e0adb5ca9596fcd7b895b16011","analyzedAt":"2026-08-21T11:28:30.864Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}