{"record":{"id":"1d3ec55b385f117b","repo":"nautechsystems/nautilus_trader","slug":"execution-transaction-hash-transaction-hash-was","errorCode":null,"errorMessage":"Execution transaction hash {transaction_hash} was not found for intent {intent_id}","messagePattern":"Execution transaction hash (.+?) was not found for intent (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/cache/database.rs","lineNumber":6830,"sourceCode":"                receipt_success = COALESCE($6, receipt_success),\n                gas_used = COALESCE($7, gas_used),\n                effective_gas_price = COALESCE($8, effective_gas_price),\n                updated_at = NOW()\n            WHERE intent_id = $1 AND transaction_hash = $2\n            \",\n        )\n        .bind(intent_id)\n        .bind(transaction_hash)\n        .bind(status.as_str())\n        .bind(block_number_db)\n        .bind(block_hash)\n        .bind(receipt_success)\n        .bind(gas_used_db)\n        .bind(effective_gas_price)\n        .execute(&mut *transaction)\n        .await\n        .map_err(|e| anyhow::anyhow!(\"Failed to update execution hash {transaction_hash}: {e}\"))?;\n        anyhow::ensure!(\n            hash_result.rows_affected() == 1,\n            \"Execution transaction hash {transaction_hash} was not found for intent {intent_id}\"\n        );\n\n        sqlx::query(\n            \"\n            UPDATE execution_intent\n            SET status = $2, active = $3, updated_at = NOW()\n            WHERE id = $1\n            \",\n        )\n        .bind(intent_id)\n        .bind(status.as_str())\n        .bind(active)\n        .execute(&mut *transaction)\n        .await\n        .map_err(|e| anyhow::anyhow!(\"Failed to update execution intent {intent_id}: {e}\"))?;\n","sourceCodeStart":6812,"sourceCodeEnd":6848,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/cache/database.rs#L6812-L6848","documentation":"Raised by anyhow::ensure! when the execution-hash UPDATE affected 0 rows, meaning no execution_transaction (or equivalent) row exists with the given transaction_hash for this intent. The status lock succeeded but the receipt references a hash that was never recorded, so the transition is rolled back.","triggerScenarios":"Calling the transition with a transaction_hash that differs from the one stored when the intent was created — e.g. a replacement/ Speedup transaction with a different hash, a hash casing/format mismatch, or the tx was never registered before its receipt was processed.","commonSituations":"Transaction replaced/repriced (speed-up/cancel) onchain so the mined hash differs from the submitted one; processing receipts before the execute call persisted the hash; mixing lowercase/0x-prefixed hash formats between the record and lookup paths; data loss or reset between registration and receipt.","solutions":["Confirm the stored hash: SELECT transaction_hash ... WHERE intent_id = '<id>'; compare exact bytes/casing with the one passed in.","Persist the execution hash before subscribing to/processing its receipt; enforce ordering in the adapter pipeline.","Handle replaced transactions: update the intent's hash when a replacement tx is submitted, before the receipt arrives.","Normalize hash format (consistent lowercase hex) at both write and lookup points."],"exampleFix":"// before\nanyhow::ensure!(\n    hash_result.rows_affected() == 1,\n    \"Execution transaction hash {transaction_hash} was not found for intent {intent_id}\"\n);\n// after\nif hash_result.rows_affected() == 0 {\n    tracing::warn!(%intent_id, %transaction_hash, \"unknown execution hash; registering receipt out-of-band\");\n    anyhow::bail!(\"Execution transaction hash {transaction_hash} was not found for intent {intent_id}\");\n}","handlingStrategy":"validation","validationCode":"// Confirm the execution hash is registered before processing its receipt\nlet known = sqlx::query_scalar::<_, bool>(\n    \"SELECT EXISTS(SELECT 1 FROM execution_transaction WHERE intent_id = $1 AND transaction_hash = $2)\")\n    .bind(&intent_id)\n    .bind(&transaction_hash)\n    .fetch_one(&pool)\n    .await?;\nif !known { register_execution_hash(&intent_id, &transaction_hash).await?; }","typeGuard":null,"tryCatchPattern":"if let Err(e) = transition.await {\n    if e.to_string().contains(\"was not found for intent\") {\n        tracing::warn!(%intent_id, %transaction_hash, \"hash not registered; check replacement tx or ordering\");\n    }\n}","preventionTips":["Persist the tx hash before subscribing to its receipt events.","Update the intent's hash whenever a replacement (speed-up/cancel) tx is submitted.","Normalize hashes to lowercase hex at both write and lookup paths."],"tags":["database","not-found","transaction-hash","idempotency"],"backgroundTag":"record-not-found","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}