{"record":{"id":"7a7ce44122ac3911","repo":"nautechsystems/nautilus_trader","slug":"execution-intent-was-not-found","errorCode":null,"errorMessage":"Execution intent {} was not found","messagePattern":"Execution intent (.+?) was not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/cache/database.rs","lineNumber":5955,"sourceCode":"        );\n\n        let (intent_chain_id, intent_wallet, intent_nonce, intent_status, intent_active) =\n            sqlx::query_as::<_, (i32, String, Option<i64>, String, bool)>(\n                \"\n            SELECT chain_id, wallet_address, nonce, status, active\n            FROM execution_intent\n            WHERE id = $1\n            FOR UPDATE\n            \",\n            )\n            .bind(assignment.intent_id)\n            .fetch_optional(&mut *transaction)\n            .await\n            .map_err(|e| {\n                anyhow::anyhow!(\"Failed to lock execution intent for nonce assignment: {e}\")\n            })?\n            .ok_or_else(|| {\n                anyhow::anyhow!(\"Execution intent {} was not found\", assignment.intent_id)\n            })?;\n        anyhow::ensure!(\n            intent_chain_id == chain_id\n                && intent_wallet == assignment.wallet_address\n                && intent_status == \"prepared\"\n                && intent_active\n                && intent_nonce.is_none_or(|assigned| assigned == nonce),\n            \"Execution intent {} cannot own canonical nonce {}\",\n            assignment.intent_id,\n            assignment.nonce\n        );\n\n        for (index, decision) in assignment.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\")?;","sourceCodeStart":5937,"sourceCodeEnd":5973,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/cache/database.rs#L5937-L5973","documentation":"The locking SELECT on `execution_intent` returned no row for the given `assignment.intent_id`, so `.ok_or_else` produces this error. The library requires the intent to exist (and later be in `prepared`/active state) before it can atomically assign the canonical nonce; a nonexistent intent means the caller is referencing an intent ID that was never created or was deleted, and the assignment is aborted.","triggerScenarios":"Calling `assign_execution_intent_nonce_verified` with an `ExecutionNonceAssignment` whose `intent_id` does not exist in the `execution_intent` table: a typo'd/stale ID, an intent created in a different database/environment, or an intent purged by retention/cleanup before assignment.","commonSituations":"Replaying a queued assignment after the intents table was truncated or migrated; pointing the app at a staging database while the intent exists in production; retrying a persisted assignment payload after the intent record was garbage-collected; mixing up intent IDs across chains.","solutions":["Confirm the intent was created via the intent-preparation flow before calling assign, and that you are using the returned intent_id verbatim.","Verify the application is connected to the same database/environment where the intent was created (check DATABASE_URL).","Check whether a cleanup/retention job or migration deleted the row; re-create the intent and re-run assignment.","Fetch the intent first (SELECT by id) as a pre-check and fail fast with a clearer application-level error if absent."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"let found = sqlx::query_scalar::<_, bool>(\"SELECT EXISTS(SELECT 1 FROM execution_intent WHERE id = $1)\")\n    .bind(&assignment.intent_id)\n    .fetch_one(pool)\n    .await?;\nif !found { return Err(anyhow!(\"intent {} does not exist; create it before nonce assignment\", assignment.intent_id)); }","typeGuard":null,"tryCatchPattern":"if let Err(e) = db.assign_execution_intent_nonce_verified(&assignment).await {\n    if e.to_string().ends_with(\"was not found\") {\n        // re-create the intent via the preparation flow before retrying\n    } else { return Err(e); }\n}","preventionTips":["Always use the intent_id returned by the intent-creation/preparation call verbatim; do not reconstruct IDs.","Pin DATABASE_URL per environment so staging code never references production intents.","Check retention/cleanup jobs do not purge prepared intents before assignment completes.","Log intent_id at creation time so stale references are easy to detect."],"tags":["database","postgres","entity-not-found","nonce-assignment"],"backgroundTag":"entity-not-found","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"}