{"record":{"id":"bbcc6ff07ad3a381","repo":"nautechsystems/nautilus_trader","slug":"active-finality-intent-was-not-found","errorCode":null,"errorMessage":"Active finality intent was not found","messagePattern":"Active finality intent was not found","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/cache/database.rs","lineNumber":7057,"sourceCode":"            );\n        }\n\n        let (current_status, intent_nonce, fill_emitted, terminal_emitted) =\n            sqlx::query_as::<_, (String, Option<i64>, bool, bool)>(\n                \"\n                SELECT status, nonce, fill_emitted, terminal_emitted\n                FROM execution_intent\n                WHERE id = $1 AND chain_id = $2 AND wallet_address = $3 AND active\n                FOR UPDATE\n                \",\n            )\n            .bind(finality.intent_id)\n            .bind(chain_id)\n            .bind(finality.wallet_address)\n            .fetch_optional(&mut *transaction)\n            .await\n            .map_err(|e| anyhow::anyhow!(\"Failed to lock intent for verified finality: {e}\"))?\n            .ok_or_else(|| anyhow::anyhow!(\"Active finality intent was not found\"))?;\n        anyhow::ensure!(\n            intent_nonce == Some(nonce)\n                && execution_transition_allowed(&current_status, finality.status),\n            \"Intent cannot make the verified finality transition\"\n        );\n\n        for (index, decision) in finality.decisions.iter().enumerate() {\n            let height_start = decision\n                .height_start\n                .map(i64::try_from)\n                .transpose()\n                .context(\"Verification height exceeds PostgreSQL BIGINT\")?;\n            let height_end = decision\n                .height_end\n                .map(i64::try_from)\n                .transpose()\n                .context(\"Verification height exceeds PostgreSQL BIGINT\")?;\n            let transition_key = format!(","sourceCodeStart":7039,"sourceCodeEnd":7075,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/cache/database.rs#L7039-L7075","documentation":"Raised when the SELECT that locks the intent for verified finality returns no row for the given (intent_id, chain_id, wallet_address). The adapter requires an existing active intent row before it will apply a verified-finality transition, so a missing row aborts the finality commit. This is a lookup miss against the intents table, not a database failure.","triggerScenarios":"Applying verified finality referencing an intent_id that was never recorded; the intent row was already closed/terminal and pruned or filtered out by the active-status WHERE clause; wallet_address or chain_id bound with different values than at intent creation.","commonSituations":"Replaying old finality events after intents were cleaned up; out-of-order message processing where finality arrives before the intent-creation write commits; environment mismatch (finality events from one DB applied against another); case/format differences in wallet_address between services.","solutions":["Confirm the intent was actually created and committed before finality is applied (check event ordering/upstream producer)","Query the intents table directly by intent_id to see whether the row exists and what its status/active flag is","Verify chain_id and wallet_address are byte-identical to those used at intent creation (checksumming, casing, network)","If intents are legitimately expired, skip or re-queue the finality event instead of retrying the same payload"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Check the intent exists and is active before applying finality\nlet active = sqlx::query_scalar::<_, Option<i64>>(\n    \"SELECT nonce FROM execution_intent \\\n     WHERE intent_id = $1 AND chain_id = $2 AND wallet_address = $3 AND active\"\n)\n.bind(&finality.intent_id).bind(chain_id).bind(finality.wallet_address)\n.fetch_optional(&mut *conn).await?;\nif active.is_none() {\n    // skip or requeue this finality event; do not attempt the transition\n}","typeGuard":"fn finality_has_known_intent(finality: &VerifiedFinality, known: &HashSet<String>) -> bool {\n    known.contains(&finality.intent_id)\n}","tryCatchPattern":"match apply_verified_finality(...).await {\n    Err(e) if e.to_string().contains(\"Active finality intent was not found\") => {\n        warn!(\"finality for unknown intent {} — requeueing\", finality.intent_id);\n        requeue(finality);\n    }\n    other => other,\n}","preventionTips":["Enforce event ordering: intent creation must commit before its finality","Normalize wallet_address and intent_id formats across services","Reconcile finality events against known intents before applying","Don't prune active intents while finality messages may still be in flight"],"tags":["database","not-found","intents","finality"],"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-14T05:17:10.506Z"}