{"record":{"id":"1a87cfbb58c78280","repo":"nautechsystems/nautilus_trader","slug":"invalid-marketstatusaction-enum-string-value-wa","errorCode":null,"errorMessage":"invalid `MarketStatusAction` enum string value, was '{value}'","messagePattern":"invalid `MarketStatusAction` enum string value, was '(.+?)'","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/model/src/ffi/enums.rs","lineNumber":600,"sourceCode":"pub extern \"C\" fn market_status_action_to_cstr(value: MarketStatusAction) -> *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 `MarketStatusAction` variant.\n#[unsafe(no_mangle)]\npub unsafe extern \"C\" fn market_status_action_from_cstr(ptr: *const c_char) -> MarketStatusAction {\n    abort_on_panic(|| {\n        let value = unsafe { cstr_as_str(ptr) };\n        MarketStatusAction::from_str(value).unwrap_or_else(|_| {\n            panic!(\"invalid `MarketStatusAction` enum string value, was '{value}'\")\n        })\n    })\n}\n\n#[unsafe(no_mangle)]\npub extern \"C\" fn oms_type_to_cstr(value: OmsType) -> *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 `OmsType` variant.","sourceCodeStart":582,"sourceCodeEnd":618,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/model/src/ffi/enums.rs#L582-L618","documentation":"market_status_action_from_cstr converts a C string into a MarketStatusAction enum via FromStr. On an unrecognized string the function panics with this message; abort_on_panic turns the panic into a process abort so it never unwinds across the C ABI. The library prefers aborting over returning a partial/undefined enum value to FFI callers.","triggerScenarios":"Calling market_status_action_from_cstr(ptr) with a string that is not a MarketStatusAction variant, e.g. 'PAUSE', 'halt', 'RESUME_TRADING', an empty string, or a buffer with trailing NUL/garbage bytes. Only strings matching the enum's FromStr impl are accepted.","commonSituations":"Translating an exchange's market-status action vocabulary (e.g. 'trading_pause') directly without mapping; passing a Python enum repr instead of its value; a version change where a MarketStatusAction variant was renamed so previously valid strings no longer parse; buffer/length mistakes when preparing the C string.","solutions":["Read the offending '{value}' in the panic message and correct it to an exact MarketStatusAction variant string (see the enum's FromStr/as_ref definitions).","Normalize/map feed or config strings to valid variant names in the caller before the FFI call.","Validate the string against the known variant list in the host language before calling.","Rebuild/reinstall so calling code and the Rust crate use the same version with matching variant names.","Ensure the C string is correctly NUL-terminated and contains no stray whitespace or garbage."],"exampleFix":"// before\nmarket_status_action_from_cstr(\"halted\"); // panics\n\n// after\nmarket_status_action_from_cstr(\"halt\"); // exact MarketStatusAction variant string","handlingStrategy":"validation","validationCode":"const MARKET_STATUS_ACTION_VARIANTS = new Set([\"open\", \"pause\", \"resume\", \"close\"]);\nif (typeof value !== \"string\" || !MARKET_STATUS_ACTION_VARIANTS.has(value)) {\n  throw new Error(`unsupported MarketStatusAction: ${value}`);\n}","typeGuard":"function isMarketStatusAction(v) { return typeof v === 'string' && MARKET_STATUS_ACTION_VARIANTS.has(v); }","tryCatchPattern":"Not applicable: panic becomes a process abort via abort_on_panic and cannot be caught. Validate inputs before the FFI call.","preventionTips":["Map exchange-specific action vocabulary to canonical variant strings explicitly.","Never pass Python enum reprs or numeric codes where variant strings are expected.","Trim whitespace and ensure NUL-terminated C strings.","Re-run binding tests after library upgrades to catch renamed variants."],"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-14T05:17:10.506Z"}