{"record":{"id":"0a1572f04deeaf88","repo":"nautechsystems/nautilus_trader","slug":"invalid-scientific-notation-format-missing-expone","errorCode":null,"errorMessage":"Invalid scientific notation format: missing exponent after 'e-'","messagePattern":"Invalid scientific notation format: missing exponent after 'e-'","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/core/src/ffi/parsing.rs","lineNumber":199,"sourceCode":"#[unsafe(no_mangle)]\npub unsafe extern \"C\" fn min_increment_precision_from_cstr(ptr: *const c_char) -> u8 {\n    abort_on_panic(|| {\n        assert!(!ptr.is_null(), \"`ptr` was NULL\");\n        // SAFETY: Caller guarantees ptr is valid per function contract\n        let s = unsafe { cstr_as_str(ptr) };\n        min_increment_precision_from_str(s)\n    })\n}\n\n// TODO: Remove this temporary parser when v1 drops its legacy source-text precision contract\nfn precision_from_v1_str(value: &str) -> u8 {\n    let value = value.trim().to_ascii_lowercase();\n\n    if value.contains(\"e-\") {\n        let exponent = value\n            .split(\"e-\")\n            .nth(1)\n            .expect(\"Invalid scientific notation format: missing exponent after 'e-'\");\n\n        if let Ok(exponent) = exponent.parse::<u64>() {\n            return u8::try_from(exponent).unwrap_or(u8::MAX);\n        }\n\n        assert!(\n            !exponent.is_empty(),\n            \"Invalid scientific notation format: missing exponent after 'e-'\"\n        );\n\n        if exponent.chars().all(|c| c.is_ascii_digit()) {\n            return u8::MAX;\n        }\n\n        panic!(\"Invalid scientific notation exponent '{exponent}': must be a valid number\");\n    }\n\n    value.split_once('.').map_or(0, |(_, decimal)| {","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/core/src/ffi/parsing.rs#L181-L217","documentation":"precision_from_v1_str in crates/core/src/ffi/parsing.rs:199 parses a decimal-precision value from a string that may use scientific notation. When the string contains 'e-', it splits on that token and unwraps the tail with expect; if no text follows 'e-' (or the split somehow yields nothing), the expect panics with \"Invalid scientific notation format: missing exponent after 'e-'\". It exists to guard an invariant the surrounding code assumes when the 'e-' token is present.","triggerScenarios":"Calling precision_from_cstr with a string like \"1.5e-\" or \"0.00012E-\" (trailing minus with no digits) — the contains(\"e-\") check matches but split(\"e-\").nth(1) yields an empty/missing segment.","commonSituations":"Hand-edited instrument config files with truncated scientific notation; a data vendor emitting malformed price precision strings like \"1e-\"; copy-paste errors where exponent digits were cut off.","solutions":["Fix the input string so the exponent digits follow 'e-' (e.g. \"1.5e-8\" instead of \"1.5e-\").","Validate the numeric string with a regex like ^\\d+(\\.\\d+)?[eE]-?\\d+$ before passing it to precision_from_cstr.","If the value comes from a config file or vendor feed, correct the source value at its origin.","Catch it in dev by unit-testing your string-producer path with precision_from_str to surface malformed notation early."],"exampleFix":"// before\nlet precision = precision_from_cstr(cstr_from(\"1.5e-\"));   // panics\n// after\nlet precision = precision_from_cstr(cstr_from(\"1.5e-8\"));  // exponent digits present","handlingStrategy":"validation","validationCode":"# Python caller\nimport re\nSCI = re.compile(r\"^\\d+(\\.\\d+)?[eE]-\\d+$\")\nassert SCI.match(value), f\"malformed scientific notation: {value!r}\"\nprecision_from_cstr(value.encode())","typeGuard":"def is_valid_scientific(value: str) -> bool:\n    import re\n    return bool(re.fullmatch(r\"\\d+(\\.\\d+)?[eE]-?\\d+\", value))","tryCatchPattern":null,"preventionTips":["Regex-validate numeric strings before FFI precision parsing.","Never hand-edit exponent values in config files; generate them programmatically.","Test your string producers with values containing 'e-' to catch truncation early."],"tags":["parsing","scientific-notation","ffi","panic"],"backgroundTag":"invalid-argument-format","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"}