{"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":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/cache/database.rs","lineNumber":3893,"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":3875,"sourceCodeEnd":3911,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/2114cf6f761429e0adb5ca9596fcd7b895b16011/crates/adapters/blockchain/src/cache/database.rs#L3875-L3911","documentation":"`mark_execution_event_emitted` persists that an order event was dispatched so it is not re-emitted after restart; it recognizes exactly three event markers — 'acknowledgement', 'fill', 'terminal' — each mapped to a guarded UPDATE. Any other string hits the catch-all bail. A second ensure in the same method also fails when the intent row is absent or the opposing marker gate rejects the update.","triggerScenarios":"Calling the method with a string other than the three exact literals: 'Fill' (wrong case), 'reject', 'ack', a trailing space, or a newly introduced event kind the running build does not know.","commonSituations":"Custom tooling calling this internal database API directly; refactors that rename event kinds without updating call sites; version mixing where a caller emits a newer event vocabulary than the database layer understands.","solutions":["Use exactly one of the lowercase literals: 'acknowledgement', 'fill', 'terminal'.","Better: model the kind as an enum and convert to the string at the boundary so invalid values fail to compile.","If the value arrives from config or a queue, validate it against the allowed set before the call.","If the string looks correct, check the follow-on ensure ('cannot mark {event} emitted') — that indicates a missing intent row or an opposing-marker conflict, not an unknown marker."],"exampleFix":"// before\nexecutor.database.mark_execution_event_emitted(intent_id, 'Fill').await?; // bails: unknown marker\n\n// after: type-safe marker\n#[derive(Clone, Copy)]\nenum ExecutionEventMarker { Acknowledgement, Fill, Terminal }\nimpl ExecutionEventMarker {\n    fn as_str(self) -> &'static str {\n        match self { Self::Acknowledgement => 'acknowledgement', Self::Fill => 'fill', Self::Terminal => 'terminal' }\n    }\n}\nexecutor.database.mark_execution_event_emitted(intent_id, ExecutionEventMarker::Fill.as_str()).await?;","handlingStrategy":"type-guard","validationCode":"const MARKERS: &[&str] = &['acknowledgement', 'fill', 'terminal'];\nanyhow::ensure!(MARKERS.contains(&event), 'event must be one of {MARKERS:?}, got {event}');","typeGuard":"#[derive(Clone, Copy)]\nenum ExecutionEventMarker { Acknowledgement, Fill, Terminal }\nimpl ExecutionEventMarker {\n    fn as_str(self) -> &'static str {\n        match self {\n            Self::Acknowledgement => 'acknowledgement',\n            Self::Fill => 'fill',\n            Self::Terminal => 'terminal',\n        }\n    }\n}\n// only ever pass marker.as_str(); invalid kinds cannot be expressed","tryCatchPattern":"Match the error: if the message starts with 'Unknown execution event marker', fix the caller's string (exact lowercase literal) — retrying with the same value will always fail. A 'cannot mark ... emitted' message instead means a missing intent row or opposing-marker conflict.","preventionTips":["Do not call this internal API with free-form strings; wrap it behind an enum.","Keep event vocabulary in one shared constant list.","Add a unit test over all call sites' event literals."],"tags":["rust","nautilustrader","database","api-contract","invalid-value","blockchain"],"backgroundTag":"invalid-enum-value","analyzedSha":"2114cf6f761429e0adb5ca9596fcd7b895b16011","analyzedAt":"2026-08-21T11:28:30.864Z","schemaVersion":2},"datasetVersion":"2026-08-22T04:17:13.399Z"}