{"record":{"id":"0e0aff7915f6b76a","repo":"nautechsystems/nautilus_trader","slug":"invalid-bybit-bbo-side-type-s-expected-queue","errorCode":null,"errorMessage":"invalid Bybit bbo_side_type: '{s}', expected Queue or Counterparty","messagePattern":"invalid Bybit bbo_side_type: '(.+?)', expected Queue or Counterparty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/bybit/src/common/parse.rs","lineNumber":1768,"sourceCode":"///\n/// # Errors\n///\n/// Returns an error for any value outside the four types Bybit accepts on an order.\npub fn deserialize_optional_smp_type<'de, D: serde::Deserializer<'de>>(\n    d: D,\n) -> Result<Option<BybitOrderSmpType>, D::Error> {\n    let Some(value) = Option::<String>::deserialize(d)? else {\n        return Ok(None);\n    };\n\n    parse_smp_type(&value).map(Some).map_err(D::Error::custom)\n}\n\npub fn parse_bbo_side_type(s: &str) -> anyhow::Result<BybitBboSideType> {\n    match s.to_ascii_lowercase().as_str() {\n        \"queue\" => Ok(BybitBboSideType::Queue),\n        \"counterparty\" => Ok(BybitBboSideType::Counterparty),\n        _ => anyhow::bail!(\"invalid Bybit bbo_side_type: '{s}', expected Queue or Counterparty\"),\n    }\n}\n\npub fn parse_bbo_level(s: String) -> anyhow::Result<String> {\n    match s.as_str() {\n        \"1\" | \"2\" | \"3\" | \"4\" | \"5\" => Ok(s),\n        _ => anyhow::bail!(\"invalid 'bbo_level': '{s}', expected 1, 2, 3, 4, or 5\"),\n    }\n}\n\n/// Parses Bybit TP/SL parameters from an optional params map.\npub fn parse_bybit_tp_sl_params(params: Option<&Params>) -> anyhow::Result<BybitTpSlParams> {\n    let Some(params) = params else {\n        return Ok(BybitTpSlParams::default());\n    };\n\n    let mut result = BybitTpSlParams {\n        is_leverage: params.get_bool(\"is_leverage\").unwrap_or(false),","sourceCodeStart":1750,"sourceCodeEnd":1786,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/bybit/src/common/parse.rs#L1750-L1786","documentation":"parse_bbo_side_type parses the bbo_side_type parameter controlling best-bid-offer (BBO) trigger behavior for TP/SL orders into the BybitBboSideType enum. Only 'queue' and 'counterparty' (case-insensitive) are valid; anything else raises this anyhow error.","triggerScenarios":"Submitting an order via py_submit_order or calling parse_bybit_tp_sl_params with params containing bbo_side_type set to something other than queue/counterparty, e.g. 'last_price' or 'mark'.","commonSituations":"Copying bbo_side_type values from Bybit UI docs for other trigger types, or confusing this option with the trigger_by parameter which uses different values.","solutions":["Set bbo_side_type to exactly 'Queue' or 'Counterparty' (case-insensitive)","Remove bbo_side_type entirely to use the default instead of an invalid value","Check you are not confusing it with trigger_by values (LastPrice, MarkPrice, IndexPrice)"],"exampleFix":"// before\nparams.insert(\"bbo_side_type\", \"LAST_PRICE\");\n// after\nparams.insert(\"bbo_side_type\", \"Queue\");","handlingStrategy":"validation","validationCode":"assert bbo_side_type.lower() in (\"queue\", \"counterparty\"), f\"invalid bbo_side_type: {bbo_side_type}\"","typeGuard":"fn is_valid_bbo_side_type(s: &str) -> bool {\n    matches!(s.to_ascii_lowercase().as_str(), \"queue\" | \"counterparty\")\n}","tryCatchPattern":"match parse_bbo_side_type(s) {\n    Ok(t) => use(t),\n    Err(e) => { log::error!(\"{e}\"); omit_bbo_side_type() }\n}","preventionTips":["Only pass 'Queue' or 'Counterparty' for bbo_side_type","Do not confuse with trigger_by values (LastPrice/MarkPrice/IndexPrice)","Validate TP/SL params before order submission"],"tags":["bybit","tpsl","bbo","invalid-enum","order"],"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"}