{"record":{"id":"be517a74e7a298d7","repo":"nautechsystems/nautilus_trader","slug":"invalid-trailingoffsettypeoptional-enum-string-v","errorCode":null,"errorMessage":"invalid `TrailingOffsetTypeOptional` enum string value, was '{value}'","messagePattern":"invalid `TrailingOffsetTypeOptional` enum string value, was '(.+?)'","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/model/src/ffi/enums.rs","lineNumber":907,"sourceCode":"}\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 `TrailingOffsetTypeOptional` variant.\n#[unsafe(no_mangle)]\npub unsafe extern \"C\" fn trailing_offset_type_from_cstr(\n    ptr: *const c_char,\n) -> TrailingOffsetTypeOptional {\n    abort_on_panic(|| {\n        let value = unsafe { cstr_as_str(ptr) };\n        TrailingOffsetTypeOptional::from_str(value).unwrap_or_else(|_| {\n            panic!(\"invalid `TrailingOffsetTypeOptional` enum string value, was '{value}'\")\n        })\n    })\n}\n\n#[unsafe(no_mangle)]\npub 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.","sourceCodeStart":889,"sourceCodeEnd":925,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/model/src/ffi/enums.rs#L889-L925","documentation":"`trailing_offset_type_from_cstr` parses a C string into `TrailingOffsetTypeOptional`, the optional-wrapped trailing offset type used at the FFI boundary. Any string not matching a variant (including the NOT_SET/None sentinel for the Optional type) panics inside `abort_on_panic`, aborting the process. Note the target type is the `Optional` wrapper, so plain `TrailingOffsetType` strings must still map to the Optional variant names.","triggerScenarios":"Calling `trailing_offset_type_from_cstr` with a raw `TrailingOffsetType` string or an empty string where the Optional \"NOT_SET\" sentinel is expected, or any misspelled value like \"PRICE\" vs \"PRICE_TAKER\".","commonSituations":"Adapters passing broker trailing-offset codes directly; forgetting that this FFI uses the Optional enum (empty string is not accepted as None); version drift where sentinel naming changed.","solutions":["Match the failing string against `TrailingOffsetTypeOptional` variant serializations and correct it.","For 'no value', pass the Optional sentinel variant string (NOT_SET) rather than an empty or null string.","Build the string via the paired `trailing_offset_type_to_cstr` to guarantee validity.","Check the calling binding for stale constant tables after upgrading nautilus_model."],"exampleFix":"// before\ntrailing_offset_type_from_cstr(str_to_cstr(\"\"));\n// after\ntrailing_offset_type_from_cstr(str_to_cstr(\"NOT_SET\"));","handlingStrategy":"validation","validationCode":"fn is_valid_trailing_offset_type_optional(s: &str) -> bool {\n    TrailingOffsetTypeOptional::from_str(s).is_ok()\n}","typeGuard":"fn as_trailing_offset_type(s: &str) -> Option<TrailingOffsetTypeOptional> {\n    TrailingOffsetTypeOptional::from_str(s).ok()\n}","tryCatchPattern":null,"preventionTips":["Remember the FFI uses the Optional enum: pass NOT_SET, never empty string, for absent values","Generate strings via the paired *_to_cstr function","Update bindings after enum/sentinel renames in new nautilus releases"],"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"}