{"record":{"id":"b9bc2dd760612e2b","repo":"nautechsystems/nautilus_trader","slug":"failed-to-decode-sbe-type-name-e","errorCode":null,"errorMessage":"failed to decode SBE {type_name}: {e}","messagePattern":"failed to decode SBE (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/common/src/msgbus/external/codec/sbe.rs","lineNumber":32,"sourceCode":"// -------------------------------------------------------------------------------------------------\n\nuse std::any::Any;\n\nuse bytes::Bytes;\nuse nautilus_model::data::{\n    Bar, FundingRateUpdate, IndexPriceUpdate, MarkPriceUpdate, OptionGreeks, OrderBookDeltas,\n    OrderBookDepth10, QuoteTick, TradeTick,\n};\nuse nautilus_serialization::sbe::{FromSbe, ToSbe};\n\nuse super::PayloadCodecError;\nuse crate::msgbus::BusPayloadType;\n\nfn deserialize_payload<T>(payload: &[u8], type_name: &str) -> anyhow::Result<T>\nwhere\n    T: FromSbe,\n{\n    T::from_sbe(payload).map_err(|e| anyhow::anyhow!(\"failed to decode SBE {type_name}: {e}\"))\n}\n\nmacro_rules! define_deserializer {\n    ($fn_name:ident, $ty:ty, $type_name:literal) => {\n        pub(crate) fn $fn_name(payload: &[u8]) -> anyhow::Result<$ty> {\n            deserialize_payload::<$ty>(payload, $type_name)\n        }\n    };\n}\n\ndefine_deserializer!(\n    deserialize_order_book_deltas,\n    OrderBookDeltas,\n    \"OrderBookDeltas\"\n);\ndefine_deserializer!(\n    deserialize_order_book_depth10,\n    OrderBookDepth10,","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/common/src/msgbus/external/codec/sbe.rs#L14-L50","documentation":"Raised by deserialize_payload in the SBE codec when T::from_sbe fails to decode a byte payload into the target type. The error wraps the underlying SBE decoding error with the message type name, indicating the payload is not a valid SBE encoding of that type (wrong type, bad schema version, or corrupt data).","triggerScenarios":"Calling a generated SBE deserializer with bytes that were not encoded by the corresponding SBE encoder; schema version mismatch between encoder and decoder; truncated or corrupted payloads.","commonSituations":"Publisher and consumer built against different message schemas; manually routing messages to the wrong codec; network or queue corruption; mixed nautilus versions exchanging SBE frames.","solutions":["Ensure the payload was encoded with the matching SBE encoder for the same message type.","Align SBE schema versions between the producing and consuming sides.","Verify payload completeness and integrity end-to-end (no truncation or corruption).","Regenerate the SBE codecs from the current schema if message definitions changed."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match sbe_deserialize_quote_tick(payload) {\n    Ok(tick) => handle(tick),\n    Err(e) if e.to_string().contains(\"failed to decode SBE\") => {\n        log::warn!(\"dropping undecodable SBE payload: {e:#}\");\n        // verify encoder schema version / dead-letter the message\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Encode and decode with codecs generated from the same SBE schema version.","Include a message type tag in the transport framing so payloads reach the right deserializer.","Add round-trip encode/decode tests for every SBE message type.","Verify payload length/framing before decoding to catch truncation early."],"tags":["rust","sbe","serialization","messaging"],"backgroundTag":"protobuf-unmarshal-failed","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"}