{"record":{"id":"664a7839441b0c04","repo":"nautechsystems/nautilus_trader","slug":"persisted-transaction-row-references-intent-ex-664a78","errorCode":null,"errorMessage":"Persisted transaction row references intent {}, expected {}","messagePattern":"Persisted transaction row references intent (.+?), expected (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/execution/sealing.rs","lineNumber":337,"sourceCode":"            to,\n            value,\n            input,\n            gas_limit: policy.gas_limit,\n            max_fee_per_gas: policy.max_fee_per_gas,\n        },\n    )\n}\n\nfn persisted_signer(intent: &ExecutionIntentRow) -> anyhow::Result<Address> {\n    Address::from_str(&intent.wallet_address).context(\"persisted execution wallet is invalid\")\n}\n\npub(crate) fn payload_context(\n    intent: &ExecutionIntentRow,\n    hash: &ExecutionTransactionHashRow,\n    deployment_id: &str,\n) -> anyhow::Result<PayloadContext> {\n    anyhow::ensure!(\n        hash.intent_id == intent.id,\n        \"Persisted transaction row references intent {}, expected {}\",\n        hash.intent_id,\n        intent.id\n    );\n    payload_context_identity(intent, &hash.transaction_hash, hash.chain_id, deployment_id)\n}\n\npub(crate) fn payload_context_identity(\n    intent: &ExecutionIntentRow,\n    transaction_hash: &str,\n    row_chain_id: u32,\n    deployment_id: &str,\n) -> anyhow::Result<PayloadContext> {\n    let nonce = intent\n        .nonce\n        .ok_or_else(|| anyhow::anyhow!(\"Execution intent {} has no signer nonce\", intent.id))?;\n    let transaction_hash = B256::from_str(transaction_hash).with_context(|| {","sourceCodeStart":319,"sourceCodeEnd":355,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/execution/sealing.rs#L319-L355","documentation":"Thrown by `payload_context` when the persisted transaction-hash row's `intent_id` does not match the given intent row's `id`. This cross-row consistency check prevents building a payload context from mismatched database rows, which would produce a wrong AAD and fail authentication downstream.","triggerScenarios":"Calling `payload_context` (directly or via open/rewrap/rollback/inspect execution payload functions) with a transaction hash row fetched for a different intent than the one passed in.","commonSituations":"Queries that join or fetch rows by non-intent keys and pass mismatched pairs, stale rows after intent re-creation (new ID but reused transaction row), or race conditions during concurrent intent processing.","solutions":["Fetch the hash row by the same intent ID used for the intent row (e.g. a keyed lookup rather than a broad query)","Check for stale/duplicate transaction rows referencing old intent IDs and clean them up","Verify ordering in concurrent code so the hash row is read after the intent row is finalized"],"exampleFix":"// before\nlet hash = store.get_hash_by_tx(tx_hash)?;\nlet ctx = payload_context(&intent, &hash, deployment_id)?;\n// after\nlet hash = store.get_hash_for_intent(intent.id)?;\nlet ctx = payload_context(&intent, &hash, deployment_id)?;","handlingStrategy":"validation","validationCode":"ensure!(hash_row.intent_id == intent_row.id, \"mismatched hash/intent rows\");\nlet ctx = payload_context(&intent_row, &hash_row, deployment_id)?;","typeGuard":null,"tryCatchPattern":"let ctx = payload_context(&intent_row, &hash_row, DEPLOYMENT_ID)\n    .context(\"hash/intent row mismatch; refetch rows by intent_id\")?;","preventionTips":["Fetch both rows in one keyed query by intent_id rather than separate lookups","Clean up orphaned transaction-hash rows when intents are recreated","Use foreign-key constraints between hash rows and intents"],"tags":["data-integrity","consistency","database"],"backgroundTag":"internal-invariant-violation","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}