{"record":{"id":"94834dae44e3901c","repo":"nautechsystems/nautilus_trader","slug":"failed-to-decode-mbomsg","errorCode":null,"errorMessage":"Failed to decode MboMsg","messagePattern":"Failed to decode MboMsg","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/databento/src/loader.rs","lineNumber":491,"sourceCode":"                    dbn_stream\n                        .advance()\n                        .map_err(|e| anyhow::anyhow!(\"Stream advance error: {e}\"))?;\n\n                    let Some(rec) = dbn_stream.get() else {\n                        return Ok(false);\n                    };\n                    let record = dbn::RecordRef::from(rec);\n                    let instrument_id = self\n                        .resolve_record_instrument_id(&record, instrument_id, &mut metadata_cache)\n                        .context(\"failed to decode instrument id\")?;\n                    let resolved_precision = self.resolve_stream_price_precision(\n                        &instrument_id,\n                        fixed_instrument_id,\n                        &mut fixed_price_precision,\n                    )?;\n                    let msg = record\n                        .get::<dbn::MboMsg>()\n                        .ok_or_else(|| anyhow::anyhow!(\"Failed to decode MboMsg\"))?;\n                    let (delta, _trade) =\n                        decode_mbo_msg(msg, instrument_id, resolved_precision, None, false)?;\n                    delta_buffer.push(msg, instrument_id, delta);\n                    Ok(true)\n                })();\n\n                match result {\n                    Ok(true) => {}\n                    Ok(false) => {\n                        delta_buffer.finish();\n                        finished = true;\n                    }\n                    Err(e) => {\n                        delta_buffer.finish();\n                        terminal_error = Some(e);\n                        finished = true;\n                    }\n                }","sourceCodeStart":473,"sourceCodeEnd":509,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/databento/src/loader.rs#L473-L509","documentation":"Inside `read_order_book_deltas`, after advancing, the record must decode as a `dbn::MboMsg`. `RecordRef::get::<MboMsg>()` returns None when the record's rtype does not correspond to MBO data, so the loader raises this error rather than silently skipping.","triggerScenarios":"Feeding a DBN stream containing non-MBO records (trades, quotes, OHLCV) into `read_order_book_deltas`/`load_order_book_deltas`, which expects rtype MBO records exclusively.","commonSituations":"Requesting the wrong schema/rtype from Databento (e.g. `trades` or `tbbo` instead of `mbo`) and piping the file into the order book delta loader; mixing multiple schemas in one file.","solutions":["Request `schema = \"mbo\"` (rtype MBO) when downloading the data from Databento","Use `load_trade_ticks`/`load_quote_ticks` for non-MBO schemas instead","Filter the stream to records with the MBO rtype before loading","Verify the file's first record header rtype with a DBN inspection tool"],"exampleFix":"// before\nlet data = databento historical.get(\n    dataset=\"GLBX.L3\", symbols=[...], schema=\"tbbo\", ...\n);\nlet deltas = loader.load_order_book_deltas(file)?; // panics with Failed to decode MboMsg\n// after\nlet data = databento historical.get(\n    dataset=\"GLBX.L3\", symbols=[...], schema=\"mbo\", ...\n);\nlet deltas = loader.load_order_book_deltas(file)?;","handlingStrategy":"validation","validationCode":"// ensure the request used the MBO schema before loading deltas\nassert_eq!(request.schema, \"mbo\", \"order book deltas require schema=mbo\");","typeGuard":"fn is_mbo_record(rec: &dbn::RecordRef) -> bool {\n    rec.get::<dbn::MboMsg>().is_some()\n}","tryCatchPattern":"match loader.load_order_book_deltas(file, instrument_id, price_precision) {\n    Ok(d) => d,\n    Err(e) if e.to_string().contains(\"Failed to decode MboMsg\") => {\n        anyhow::bail!(\"input is not MBO data; re-download with schema=mbo\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Always request `schema=\"mbo\"` for order book delta workflows","Route trades/tbbo/ohlcv files to their dedicated loaders","Inspect the DBN header rtype before choosing a loader"],"tags":["databento","order-book","record-type-mismatch"],"backgroundTag":"incompatible-source-type","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"}