{"record":{"id":"13b137afbff0eeee","repo":"nautechsystems/nautilus_trader","slug":"invalid-ototriggermode-enum-string-value-was","errorCode":null,"errorMessage":"invalid `OtoTriggerMode` enum string value, was '{value}'","messagePattern":"invalid `OtoTriggerMode` enum string value, was '(.+?)'","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/model/src/ffi/enums.rs","lineNumber":670,"sourceCode":"pub extern \"C\" fn oto_trigger_mode_to_cstr(value: OtoTriggerMode) -> *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 `OtoTriggerMode` variant.\n#[unsafe(no_mangle)]\npub unsafe extern \"C\" fn oto_trigger_mode_from_cstr(ptr: *const c_char) -> OtoTriggerMode {\n    abort_on_panic(|| {\n        let value = unsafe { cstr_as_str(ptr) };\n        OtoTriggerMode::from_str(value)\n            .unwrap_or_else(|_| panic!(\"invalid `OtoTriggerMode` enum string value, was '{value}'\"))\n    })\n}\n\n#[unsafe(no_mangle)]\npub extern \"C\" fn order_side_to_cstr(value: OrderSideOptional) -> *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 `OrderSideOptional` variant.\n#[unsafe(no_mangle)]","sourceCodeStart":652,"sourceCodeEnd":688,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/model/src/ffi/enums.rs#L652-L688","documentation":"oto_trigger_mode_from_cstr converts a C string into an OtoTriggerMode enum via FromStr. Any string that does not match a variant triggers this panic, which abort_on_panic converts to a process abort at the FFI boundary. This prevents undefined enum values from crossing into Rust from C callers.","triggerScenarios":"Calling oto_trigger_mode_from_cstr(ptr) with a string not accepted by OtoTriggerMode::from_str, e.g. 'ONE_TRIGGER_ONE', 'OTO_ORDER', an empty string, or a mis-terminated buffer. Only exact variant strings parse.","commonSituations":"Wiring contingent-order (OTO) configuration over FFI with hand-written mode strings; passing config values in the wrong case; a rename of the enum variant between versions so old callers pass stale names; whitespace picked up from config files.","solutions":["Use the exact OtoTriggerMode variant string; compare against the '{value}' in the panic and the enum's FromStr definition.","Trim and normalize the incoming string in the host language before the FFI call.","Validate against the known variant list before calling.","Check case sensitivity — variant strings are matched exactly.","Rebuild the caller against the same crate version if the enum was renamed."],"exampleFix":"// before\noto_trigger_mode_from_cstr(\"OTO_ORDER\"); // panics\n\n// after\noto_trigger_mode_from_cstr(\"linked_or_least_one\"); // exact variant string per enum definition","handlingStrategy":"validation","validationCode":"const OTO_TRIGGER_MODE_VARIANTS = new Set([\"linked_or_least_one\"]);\nif (typeof mode !== \"string\" || !OTO_TRIGGER_MODE_VARIANTS.has(mode)) {\n  throw new Error(`unsupported OtoTriggerMode: ${mode}`);\n}","typeGuard":"function isOtoTriggerMode(v) { return typeof v === 'string' && OTO_TRIGGER_MODE_VARIANTS.has(v); }","tryCatchPattern":"Not applicable: the panic becomes a process abort; no catch is possible. Validate the mode string before the FFI call.","preventionTips":["Use library-provided enum constants for trigger modes instead of literals.","Trim config values and enforce exact case before calling.","Whitelist variant strings in the wrapper layer.","Regenerate bindings after crate upgrades to detect renames."],"tags":["ffi","panic","enum-parsing","rust"],"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-14T00:17:10.932Z"}