{"record":{"id":"993d9f7b03a71b63","repo":"nautechsystems/nautilus_trader","slug":"invalid-liquidityside-enum-string-value-was-v","errorCode":null,"errorMessage":"invalid `LiquiditySide` enum string value, was '{value}'","messagePattern":"invalid `LiquiditySide` enum string value, was '(.+?)'","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/model/src/ffi/enums.rs","lineNumber":554,"sourceCode":"pub extern \"C\" fn liquidity_side_to_cstr(value: LiquiditySide) -> *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 `LiquiditySide` variant.\n#[unsafe(no_mangle)]\npub unsafe extern \"C\" fn liquidity_side_from_cstr(ptr: *const c_char) -> LiquiditySide {\n    abort_on_panic(|| {\n        let value = unsafe { cstr_as_str(ptr) };\n        LiquiditySide::from_str(value)\n            .unwrap_or_else(|_| panic!(\"invalid `LiquiditySide` enum string value, was '{value}'\"))\n    })\n}\n\n#[unsafe(no_mangle)]\npub extern \"C\" fn market_status_to_cstr(value: MarketStatus) -> *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 `MarketStatus` variant.\n#[unsafe(no_mangle)]","sourceCodeStart":536,"sourceCodeEnd":572,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/model/src/ffi/enums.rs#L536-L572","documentation":"`liquidity_side_from_cstr` parses a C string into the Rust `LiquiditySide` enum (e.g. MAKER/TAKER) and panics if the string is not a recognized variant. Because the function is exported across the C FFI, the panic is converted by `abort_on_panic` into a process abort instead of unwinding into foreign code. Only exact canonical strings from `liquidity_side_to_cstr` are accepted.","triggerScenarios":"Calling `liquidity_side_from_cstr(ptr)` with strings like 'maker'/'taker' in wrong case, short codes like 'M', an empty string, or a value taken from an exchange's liquidity indicator that differs from the canonical enum spelling.","commonSituations":"Parsing execution/position reports in adapters where venue liquidity flags must be mapped to `LiquiditySide`; typos in adapter code; case normalization mistakes; serialization changes between versions.","solutions":["Log the exact string and diff against the canonical `LiquiditySide` variant spellings.","Map venue liquidity indicators explicitly to `LiquiditySide` strings at the adapter boundary.","Normalize case and trim whitespace before calling; the match is exact.","Generate strings via `liquidity_side_to_cstr` from enum values rather than literals.","Validate the string against the accepted set before the FFI call, since invalid input aborts the process."],"exampleFix":"// before\nliq = \"M\"\nliquidity_side_from_cstr(liq.encode())\n// after\nliq = \"MAKER\"  # canonical LiquiditySide spelling\nliquidity_side_from_cstr(liq.encode())","handlingStrategy":"validation","validationCode":"VALID_LIQUIDITY_SIDES = {\"NO_LIQUIDITY_SIDE\", \"MAKER\", \"TAKER\"}  # verify against LiquiditySide definition\nassert liq_str in VALID_LIQUIDITY_SIDES, f\"bad LiquiditySide: {liq_str!r}\"\nliquidity_side_from_cstr(liq_str.encode())","typeGuard":"def is_valid_liquidity_side(s: str) -> bool:\n    return s in VALID_LIQUIDITY_SIDES  # canonical strings from LiquiditySide::as_ref","tryCatchPattern":null,"preventionTips":["Map exchange liquidity indicators (e.g. 'M'/'T') to LiquiditySide strings explicitly.","Normalize case before the FFI call.","Validate against the canonical set before calling; failure aborts the process.","Generate strings via liquidity_side_to_cstr from enum values.","Round-trip test hard-coded strings in CI and after upgrades."],"tags":["ffi","rust","panic","enum-parsing","process-abort"],"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"}