nautechsystems/nautilus_trader · error · anyhow::Error
SBE decoding requires the `sbe` feature
Error message
SBE decoding requires the `sbe` feature
What it means
The message bus SBE codec stubs are compiled in when the `sbe` cargo feature is disabled. Every SBE deserializer (e.g. for OrderBookDeltas or OrderBookDepth10) immediately bails with this error because SBE decoding is simply not compiled into the binary. The library throws it to make the missing-feature condition explicit instead of returning garbage or panicking.
Source
Thrown at crates/common/src/msgbus/external/codec/sbe_unavailable.rs:30
// See the License for the specific language governing permissions and
// limitations under the License.
// -------------------------------------------------------------------------------------------------
use std::any::Any;
use bytes::Bytes;
use nautilus_model::data::{
Bar, FundingRateUpdate, IndexPriceUpdate, MarkPriceUpdate, OptionGreeks, OrderBookDeltas,
OrderBookDepth10, QuoteTick, TradeTick,
};
use super::PayloadCodecError;
use crate::msgbus::BusPayloadType;
macro_rules! define_deserializer {
($fn_name:ident, $ty:ty) => {
pub(crate) fn $fn_name(_payload: &[u8]) -> anyhow::Result<$ty> {
anyhow::bail!("SBE decoding requires the `sbe` feature")
}
};
}
define_deserializer!(deserialize_order_book_deltas, OrderBookDeltas);
define_deserializer!(deserialize_order_book_depth10, OrderBookDepth10);
define_deserializer!(deserialize_quote, QuoteTick);
define_deserializer!(deserialize_trade, TradeTick);
define_deserializer!(deserialize_bar, Bar);
define_deserializer!(deserialize_mark_price, MarkPriceUpdate);
define_deserializer!(deserialize_index_price, IndexPriceUpdate);
define_deserializer!(deserialize_funding_rate, FundingRateUpdate);
define_deserializer!(deserialize_option_greeks, OptionGreeks);
pub(super) fn serialize_payload(
payload_type: BusPayloadType,
_message: &dyn Any,
) -> Result<Bytes, PayloadCodecError> {View on GitHub (pinned to 18893faf8b)
Solutions
- Enable the `sbe` feature: add `features = ["sbe"]` to the nautilus_common dependency in Cargo.toml or build with `cargo build --features sbe`.
- Switch the bus payload codec to a supported one (e.g. JSON) so SBE deserializers are never invoked.
- Verify with `cargo tree -e features` that the feature actually reaches the final binary and not just an intermediate crate.
Example fix
// before (Cargo.toml)
nautilus-common = "0.x"
// after
nautilus-common = { version = "0.x", features = ["sbe"] } Defensive patterns
Strategy: validation
Validate before calling
# build-time / runtime check that the sbe feature is present
if not hasattr(codec_module, "sbe_enabled") or not codec_module.sbe_enabled:
raise RuntimeError("SBE codec unavailable: rebuild with --features sbe") Prevention
- Enable the `sbe` feature in the workspace dependency declaration so all binaries get it.
- Add a CI build with production feature flags identical to release.
- Document which payload codecs require which features near the bus configuration.
When it happens
Trigger: Calling any `deserialize_*` function in crates/common/src/msgbus/external/codec/sbe_unavailable.rs (deserialize_order_book_deltas, deserialize_order_book_depth10) while the crate was built without the `sbe` feature — e.g. decoding an SBE-encoded payload from an external message bus endpoint.
Common situations: Running a default `cargo build` (features off) and then pointing the message bus at a topic that publishes SBE-framed payloads; a workspace depending on nautilus_common without enabling `features = ["sbe"]`; CI or docker images built with default features.
Related errors
- SBE encoding is not supported for Redis cache payloads
- failed to decode SBE {type_name}: {e}
- Symbol '{}' is not trading (status: {})
- Buffer too short for SBE header: expected {HEADER_LEN}, was
- Wrong template ID: expected {execution_report_event_codec::S
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/a257904fcb2d6967.
Report an issue: GitHub.