{"record":{"id":"226807f72a4d99cb","repo":"nautechsystems/nautilus_trader","slug":"invalid-triggertypeoptional-enum-string-value-w","errorCode":null,"errorMessage":"invalid `TriggerTypeOptional` enum string value, was '{value}'","messagePattern":"invalid `TriggerTypeOptional` enum string value, was '(.+?)'","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/model/src/ffi/enums.rs","lineNumber":931,"sourceCode":"pub extern \"C\" fn trigger_type_to_cstr(value: TriggerTypeOptional) -> *const c_char {\n    str_to_cstr(value.as_ref())\n}\n\n/// Returns an enum from a C string.\n///\n/// # Safety\n///\n/// Assumes `ptr` is a valid C string pointer.\n///\n/// # Panics\n///\n/// Panics if the C string does not correspond to a valid `TriggerTypeOptional` variant.\n#[unsafe(no_mangle)]\npub unsafe extern \"C\" fn trigger_type_from_cstr(ptr: *const c_char) -> TriggerTypeOptional {\n    abort_on_panic(|| {\n        let value = unsafe { cstr_as_str(ptr) };\n        TriggerTypeOptional::from_str(value).unwrap_or_else(|_| {\n            panic!(\"invalid `TriggerTypeOptional` enum string value, was '{value}'\")\n        })\n    })\n}\n\n#[cfg(test)]\nmod tests {\n    use rstest::rstest;\n\n    use super::*;\n    use crate::enums::OrderSide;\n\n    #[rstest]\n    fn test_name() {\n        assert_eq!(OrderSideOptional::NoOrderSide.as_ref(), \"NO_ORDER_SIDE\");\n        assert_eq!(OrderSide::Buy.as_ref(), \"BUY\");\n        assert_eq!(OrderSide::Sell.as_ref(), \"SELL\");\n    }\n","sourceCodeStart":913,"sourceCodeEnd":949,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/model/src/ffi/enums.rs#L913-L949","documentation":"`trigger_type_from_cstr` parses a C string into `TriggerTypeOptional` (the optional-wrapped trigger type: DEFAULT, LAST, BID, ASK, etc.). Invalid strings panic inside `abort_on_panic` and abort the process, since the FFI layer treats unparseable enum values as unrecoverable programming errors. Only exact `TriggerTypeOptional::as_ref()` serializations are valid.","triggerScenarios":"Calling the exported `trigger_type_from_cstr` with strings like \"last_price\", \"MIDPOINT\" (not a trigger variant), or an empty string instead of the NOT_SET sentinel.","commonSituations":"Exchange trigger-price conventions mapped 1:1 without translation; configs storing lowercase trigger names; confusion between TriggerType and TriggerTypeOptional serializations.","solutions":["Correct the input string to an exact `TriggerTypeOptional` variant name.","Use NOT_SET for absent values instead of empty strings or NULL.","Generate valid strings via `trigger_type_to_cstr` round-tripping.","Update adapter mappings so exchange trigger codes translate to canonical nautilus trigger names."],"exampleFix":"// before\ntrigger_type_from_cstr(str_to_cstr(\"last_price\"));\n// after\ntrigger_type_from_cstr(str_to_cstr(\"LAST\"));","handlingStrategy":"validation","validationCode":"fn is_valid_trigger_type_optional(s: &str) -> bool {\n    TriggerTypeOptional::from_str(s).is_ok()\n}","typeGuard":"fn as_trigger_type(s: &str) -> Option<TriggerTypeOptional> {\n    TriggerTypeOptional::from_str(s).ok()\n}","tryCatchPattern":null,"preventionTips":["Map exchange trigger conventions to canonical nautilus trigger names in adapters","Use NOT_SET for absent trigger types instead of empty strings","Round-trip via trigger_type_to_cstr to validate constants"],"tags":["ffi","rust","enum-parsing","panic"],"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-14T05:17:10.506Z"}