{"record":{"id":"ecc49e2647666f24","repo":"nautechsystems/nautilus_trader","slug":"invalid-ordersideoptional-enum-string-value-was","errorCode":null,"errorMessage":"invalid `OrderSideOptional` enum string value, was '{value}'","messagePattern":"invalid `OrderSideOptional` enum string value, was '(.+?)'","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/model/src/ffi/enums.rs","lineNumber":693,"sourceCode":"pub 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)]\npub unsafe extern \"C\" fn order_side_from_cstr(ptr: *const c_char) -> OrderSideOptional {\n    abort_on_panic(|| {\n        let value = unsafe { cstr_as_str(ptr) };\n        OrderSideOptional::from_str(value).unwrap_or_else(|_| {\n            panic!(\"invalid `OrderSideOptional` enum string value, was '{value}'\")\n        })\n    })\n}\n\n#[unsafe(no_mangle)]\npub extern \"C\" fn order_status_to_cstr(value: OrderStatus) -> *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 `OrderStatus` variant.","sourceCodeStart":675,"sourceCodeEnd":711,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/model/src/ffi/enums.rs#L675-L711","documentation":"order_side_from_cstr converts a C string into an OrderSideOptional enum via FromStr. Unrecognized strings panic with this message; abort_on_panic turns the panic into a process abort at the FFI boundary. OrderSideOptional includes a NO_ORDER_SIDE/none-style variant, so callers should use that rather than an empty or ad-hoc string.","triggerScenarios":"Calling order_side_from_cstr(ptr) with strings like 'BUY_ORDER', 'Long', 'flat', '0', or an empty string that do not match any OrderSideOptional variant. Only exact variant strings accepted by FromStr parse; empty input will NOT map to the none variant.","commonSituations":"Mapping broker-side side vocabulary ('B'/'S', 'long'/'short') directly into the FFI call; passing None/empty where the 'NO_ORDER_SIDE' variant string is required; case mismatches; version drift after a rename.","solutions":["Pass the exact OrderSideOptional variant string (e.g. 'BUY', 'SELL', or the none-variant string) per the enum's FromStr definition.","For missing/neutral sides, explicitly pass the none-variant string instead of an empty string.","Map feed-specific side codes ('B'/'S') to canonical variants in the caller.","Validate the string against the variant whitelist before calling.","Rebuild against the matching crate version if variant names changed."],"exampleFix":"// before\norder_side_from_cstr(\"\"); // panics: empty string\n\n// after\norder_side_from_cstr(\"NO_ORDER_SIDE\"); // explicit none-variant string","handlingStrategy":"validation","validationCode":"const ORDER_SIDE_OPTIONAL_VARIANTS = new Set([\"BUY\", \"SELL\", \"NO_ORDER_SIDE\"]);\nfunction toOrderSideOptional(raw) {\n  const v = raw == null || raw === \"\" ? \"NO_ORDER_SIDE\" : raw;\n  if (!ORDER_SIDE_OPTIONAL_VARIANTS.has(v)) throw new Error(`unsupported OrderSideOptional: ${raw}`);\n  return v;\n}","typeGuard":"function isOrderSideOptional(v) { return v === 'BUY' || v === 'SELL' || v === 'NO_ORDER_SIDE'; }","tryCatchPattern":"Not applicable: panics abort the process at the FFI boundary and cannot be caught. Convert null/empty to the explicit none-variant string beforehand.","preventionTips":["Map 'B'/'S', 'long'/'short' codes to canonical BUY/SELL before the call.","Never pass empty strings where the NO_ORDER_SIDE variant is intended.","Validate every side value in the wrapper before crossing FFI.","Keep an explicit venue-to-variant mapping table with tests."],"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"}