{"record":{"id":"12c1f300f6e4d80c","repo":"nautechsystems/nautilus_trader","slug":"invalid-type-for-bbo-level-value-expected-st","errorCode":null,"errorMessage":"invalid type for 'bbo_level': {value}, expected string or integer","messagePattern":"invalid type for 'bbo_level': (.+?), expected string or integer","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/bybit/src/common/parse.rs","lineNumber":1946,"sourceCode":"        anyhow::bail!(\"'bbo_side_type' and 'bbo_level' must be provided together\");\n    }\n\n    if let Some(value) = params.get(\"bbo_side_type\") {\n        let side_type = value.as_str().ok_or_else(|| {\n            anyhow::anyhow!(\"invalid type for 'bbo_side_type': {value}, expected string\")\n        })?;\n        result.bbo_side_type = Some(parse_bbo_side_type(side_type)?);\n    }\n\n    if let Some(value) = params.get(\"bbo_level\") {\n        let level = if let Some(s) = value.as_str() {\n            s.to_string()\n        } else if let Some(i) = value.as_i64() {\n            i.to_string()\n        } else if let Some(u) = value.as_u64() {\n            u.to_string()\n        } else {\n            anyhow::bail!(\"invalid type for 'bbo_level': {value}, expected string or integer\");\n        };\n        result.bbo_level = Some(parse_bbo_level(level)?);\n    }\n\n    Ok(result)\n}\n\npub(crate) fn parse_trigger_type(s: &str) -> anyhow::Result<BybitTriggerType> {\n    match s {\n        \"LastPrice\" => Ok(BybitTriggerType::LastPrice),\n        \"MarkPrice\" => Ok(BybitTriggerType::MarkPrice),\n        \"IndexPrice\" => Ok(BybitTriggerType::IndexPrice),\n        _ => anyhow::bail!(\n            \"invalid Bybit trigger type: '{s}', expected LastPrice, MarkPrice, or IndexPrice\"\n        ),\n    }\n}\n","sourceCodeStart":1928,"sourceCodeEnd":1964,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/bybit/src/common/parse.rs#L1928-L1964","documentation":"The 'bbo_level' value must be a string or an integer (i64/u64) so it can be normalized to a level string and parsed via parse_bbo_level. Any other JSON type (float, bool, null, object) triggers this bail with the offending value in the message.","triggerScenarios":"Passing 'bbo_level' as a float (e.g. 1.5), bool, null, or nested value while 'bbo_side_type' is also present.","commonSituations":"YAML/JSON config where the level was parsed as a float; untyped deserialization producing f64 for whole numbers.","solutions":["Pass 'bbo_level' as a string (e.g. \"1\") or a JSON integer","Ensure the config source emits whole numbers, not floats, for bbo_level","Check that the value also passes parse_bbo_level (valid level format) after fixing the type"],"exampleFix":"// before\nparams.set(\"bbo_level\", 1.5);\n// after\nparams.set(\"bbo_level\", \"1\");","handlingStrategy":"type-guard","validationCode":"fn validate_bbo_level(params: &Params) -> Result<(), String> {\n    if let Some(v) = params.get(\"bbo_level\") {\n        if !(v.is_string() || v.is_i64() || v.is_u64()) {\n            return Err(format!(\"bbo_level must be string or integer, got {v}\"));\n        }\n    }\n    Ok(())\n}","typeGuard":"fn is_bbo_level_like(v: &Value) -> bool {\n    v.is_string() || v.is_i64() || v.is_u64()\n}","tryCatchPattern":"match parse_bybit_tp_sl_params(&params) {\n    Ok(p) => submit(p),\n    Err(e) if e.to_string().contains(\"invalid type for 'bbo_level'\") => {\n        log::warn(\"bbo_level must be a string or integer, not a float/bool/null\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Emit bbo_level as an integer or string, never a float","Configure YAML/JSON parsers to keep whole numbers as ints","Pre-validate the value against the level format expected by parse_bbo_level"],"tags":["bybit","type-mismatch","bbo","params-validation"],"backgroundTag":"type-mismatch","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"}