{"record":{"id":"c2b851b90ea43136","repo":"nautechsystems/nautilus_trader","slug":"execution-intent-intent-id-was-not-found","errorCode":null,"errorMessage":"Execution intent {intent_id} was not found","messagePattern":"Execution intent (.+?) was not found","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/cache/database.rs","lineNumber":3624,"sourceCode":"            format!(\n                \"Execution gas used {} exceeds PostgreSQL BIGINT\",\n                gas_used.unwrap_or_default()\n            )\n        })?;\n        let mut transaction = self\n            .pool\n            .begin()\n            .await\n            .map_err(|e| anyhow::anyhow!(\"Failed to start execution status transition: {e}\"))?;\n        let (current_status, fill_emitted, terminal_emitted) =\n            sqlx::query_as::<_, (String, bool, bool)>(\n            \"SELECT status, fill_emitted, terminal_emitted FROM execution_intent WHERE id = $1 FOR UPDATE\",\n        )\n        .bind(intent_id)\n        .fetch_optional(&mut *transaction)\n        .await\n        .map_err(|e| anyhow::anyhow!(\"Failed to lock execution intent {intent_id}: {e}\"))?\n        .ok_or_else(|| anyhow::anyhow!(\"Execution intent {intent_id} was not found\"))?;\n        anyhow::ensure!(\n            execution_transition_allowed(&current_status, status),\n            \"Invalid execution transition for intent {intent_id}: {current_status} -> {}\",\n            status.as_str()\n        );\n\n        let active = match status {\n            TransactionStatus::Finalized | TransactionStatus::Reverted => {\n                !fill_emitted && !terminal_emitted\n            }\n            TransactionStatus::Recoverable => false,\n            _ => true,\n        };\n        let hash_result = sqlx::query(\n            \"\n            UPDATE execution_transaction_hash\n            SET status = $3,\n                block_number = COALESCE($4, block_number),","sourceCodeStart":3606,"sourceCodeEnd":3642,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/2114cf6f761429e0adb5ca9596fcd7b895b16011/crates/adapters/blockchain/src/cache/database.rs#L3606-L3642","documentation":"Thrown when the FOR UPDATE lookup in record_execution_status finds no execution_intent row with the given id. The id must originate from the ExecutionIntentRow returned by reserve_execution_intent; passing a v1 execution_transaction hash, a hash-table row id, an invented id, or running against a database that was reset while the process kept in-memory state all produce this.","triggerScenarios":"Calling record_execution_status with a transaction hash or execution_transaction_hash.id instead of the intent id; the schema was dropped and recreated between reserve and record; recording an observation before the reservation committed.","commonSituations":"Mixed-version code paths confusing v1 and v2 identifiers; test environments recreating the cache schema; database restored from a snapshot while workers kept state.","solutions":["Trace the value back to the ExecutionIntentRow returned by reserve_execution_intent - only that id is valid","When starting from a transaction hash, resolve intent_id via execution_transaction_hash first and use that","After any database reset or restore, rebuild in-memory state before recording observations"],"exampleFix":"// before: recording with an id that is not the intent id\ndb.record_execution_status(hash_row.id, &tx_hash, status, ...).await?;\n\n// after: resolve the owning intent first\nlet intent_id: i64 = sqlx::query_scalar(\n    \"SELECT intent_id FROM execution_transaction_hash WHERE chain_id = $1 AND transaction_hash = $2\",\n)\n.bind(chain_id)\n.bind(&tx_hash)\n.fetch_one(&pool)\n.await?;\ndb.record_execution_status(intent_id, &tx_hash, status, ...).await?;","handlingStrategy":"validation","validationCode":"// Confirm the intent exists before recording an observation\nlet exists: bool = sqlx::query_scalar(\"SELECT EXISTS (SELECT 1 FROM execution_intent WHERE id = $1)\")\n    .bind(intent_id)\n    .fetch_one(&pool)\n    .await?;\nif !exists { /* resolve via execution_transaction_hash or re-reserve */ }","typeGuard":"fn is_intent_id(id: i64, reserved: &ExecutionIntentRow) -> bool {\n    id == reserved.id\n}","tryCatchPattern":"match db.record_execution_status(intent_id, &tx_hash, status, block, hash, success, gas, price).await {\n    Err(e) if e.to_string().contains(\"was not found\") => {\n        // resolve the correct intent_id from execution_transaction_hash, or drop stale in-memory state\n    }\n    other => other?,\n}","preventionTips":["Carry the ExecutionIntentRow returned by reserve_execution_intent and use its id everywhere downstream","Never substitute a transaction hash or hash-table row id where intent_id is expected","After database resets or restores, rebuild in-memory execution state before recording anything"],"tags":["rust","sqlx","postgresql","not-found","execution-intent","identifier-mismatch"],"backgroundTag":"record-not-found","analyzedSha":"2114cf6f761429e0adb5ca9596fcd7b895b16011","analyzedAt":"2026-08-21T11:28:30.864Z","schemaVersion":2},"datasetVersion":"2026-08-22T04:17:13.399Z"}