{"record":{"id":"c95f96993393ede2","repo":"nautechsystems/nautilus_trader","slug":"unknown-execution-event-marker-event","errorCode":null,"errorMessage":"Unknown execution event marker {event}","messagePattern":"Unknown execution event marker (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/cache/database.rs","lineNumber":7372,"sourceCode":"    ///\n    /// Returns an error if the event kind is unknown, the intent is absent, the opposing\n    /// terminal marker is already set, or persistence fails.\n    pub async fn mark_execution_event_emitted(\n        &self,\n        intent_id: i64,\n        event: &str,\n    ) -> anyhow::Result<()> {\n        let statement = match event {\n            \"acknowledgement\" => {\n                \"UPDATE execution_intent SET acknowledgement_emitted = TRUE, updated_at = NOW() WHERE id = $1\"\n            }\n            \"fill\" => {\n                \"UPDATE execution_intent SET fill_emitted = TRUE, active = CASE WHEN status = 'finalized' THEN FALSE ELSE active END, updated_at = NOW() WHERE id = $1 AND NOT terminal_emitted\"\n            }\n            \"terminal\" => {\n                \"UPDATE execution_intent SET terminal_emitted = TRUE, active = CASE WHEN status IN ('finalized', 'reverted') THEN FALSE ELSE active END, updated_at = NOW() WHERE id = $1 AND NOT fill_emitted\"\n            }\n            _ => anyhow::bail!(\"Unknown execution event marker {event}\"),\n        };\n        let result = sqlx::query(statement)\n            .bind(intent_id)\n            .execute(&self.pool)\n            .await\n            .map_err(|e| anyhow::anyhow!(\"Failed to mark execution {event} emitted: {e}\"))?;\n        anyhow::ensure!(\n            result.rows_affected() == 1,\n            \"Execution intent {intent_id} cannot mark {event} emitted\"\n        );\n        Ok(())\n    }\n\n    /// Updates the status of a persisted execution transaction record.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the database operation fails.","sourceCodeStart":7354,"sourceCodeEnd":7390,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/cache/database.rs#L7354-L7390","documentation":"BlockchainExecutionDatabase::mark_execution_emitted matches an execution event marker string against known variants (e.g. \"fill\", \"terminal\") to pick the SQL UPDATE statement. When called with any other marker string, the catch-all arm aborts with anyhow::bail! before any query is executed. It is a guard against typos or newly added marker kinds that the database layer has not been taught to handle.","triggerScenarios":"Calling mark_execution_emitted(intent_id, event) with an event marker other than \"fill\" or \"terminal\" — e.g. a misspelled marker like \"filled\", a renamed marker after a refactor, or a new execution event kind added upstream in the emission logic without a matching match arm here.","commonSituations":"Developers adding a new execution lifecycle stage (e.g. \"intent\", \"cancel\") forget to extend the match in database.rs; callers pass user- or config-supplied event names; a version mismatch where the caller crate emits a marker this adapter version does not know.","solutions":["Check the event string passed to mark_execution_emitted and correct the typo or casing (valid values: \"fill\", \"terminal\").","If a new execution event marker is legitimately needed, add a match arm in crates/adapters/blockchain/src/cache/database.rs (~line 7372) with the appropriate UPDATE statement before the catch-all.","Grep the codebase for mark_execution_emitted call sites and align the marker constants used there with the match arms.","If versions diverge, update the blockchain adapter and the calling crate to matching versions."],"exampleFix":"// before\nlet marker = \"filled\";\ndb.mark_execution_emitted(intent_id, marker).await?;\n// after\nlet marker = \"fill\"; // must be \"fill\" or \"terminal\"\ndb.mark_execution_emitted(intent_id, marker).await?;","handlingStrategy":"validation","validationCode":"const VALID_MARKERS: [&str; 2] = [\"fill\", \"terminal\"];\nif !VALID_MARKERS.contains(&event) {\n    return Err(anyhow::anyhow!(\"Unknown execution event marker {event}; expected one of {VALID_MARKERS:?}\"));\n}\ndb.mark_execution_emitted(intent_id, event).await?;","typeGuard":null,"tryCatchPattern":"match db.mark_execution_emitted(intent_id, event).await {\n    Ok(_) => { /* proceed */ }\n    Err(e) if e.to_string().contains(\"Unknown execution event marker\") => {\n        log::error!(\"event marker '{event}' not supported by db layer: {e}\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Define execution event markers as a Rust enum with Display, and convert to string only at the db boundary.","Keep marker constants in one shared module used by both callers and the database layer.","Add a unit test asserting mark_execution_emitted accepts exactly the supported markers."],"tags":["rust","anyhow","database","invalid-argument"],"backgroundTag":"invalid-enum-value","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"}