nautechsystems/nautilus_trader · error
SBE encoding is not supported for Redis cache payloads
Error message
SBE encoding is not supported for Redis cache payloads
What it means
serialize_payload in the Redis query/cache layer supports only MsgPack and Json encodings for turning a payload into bytes stored in Redis. SBE (Simple Binary Encoding) has no serializer wired into this code path, so requesting it is rejected immediately with an anyhow error rather than producing corrupt or empty data.
Source
Thrown at crates/infrastructure/src/redis/queries.rs:96
pub fn serialize_payload<T: Serialize>(
encoding: SerializationEncoding,
payload: &T,
) -> anyhow::Result<Vec<u8>> {
match encoding {
SerializationEncoding::MsgPack => {
let mut value = serde_json::to_value(payload)?;
convert_timestamps(&mut value);
rmp_serde::to_vec(&value)
.map_err(|e| anyhow::anyhow!("Failed to serialize msgpack `payload`: {e}"))
}
SerializationEncoding::Json => {
let mut value = serde_json::to_value(payload)?;
convert_timestamps(&mut value);
serde_json::to_vec(&value)
.map_err(|e| anyhow::anyhow!("Failed to serialize json `payload`: {e}"))
}
SerializationEncoding::Sbe => {
anyhow::bail!("SBE encoding is not supported for Redis cache payloads")
}
SerializationEncoding::Capnp => {
anyhow::bail!("Cap'n Proto encoding is not supported for Redis cache payloads")
}
}
}
/// Deserializes the given byte slice `payload` into type `T` using the specified `encoding`.
///
/// # Errors
///
/// Returns an error if deserialization from the chosen encoding fails or converting to the target type fails.
pub fn deserialize_payload<T: DeserializeOwned>(
encoding: SerializationEncoding,
payload: &[u8],
) -> anyhow::Result<T> {
let mut value = match encoding {
SerializationEncoding::MsgPack => rmp_serde::from_slice(payload)View on GitHub (pinned to 18893faf8b)
Solutions
- Change the cache serialization setting to SerializationEncoding::MsgPack or Json for Redis cache usage.
- Separate the serialization config for the Redis client from any SBE-configured clients so SBE is not inherited.
- If SBE support is genuinely needed for Redis cache payloads, implement the SBE branch in serialize_payload in crates/infrastructure/src/redis/queries.rs.
- Validate the configured encoding at startup and fail fast with a clear config error before connecting.
Example fix
// before
let settings = SerializationSettings { encoding: SerializationEncoding::Sbe, .. };
// after
let settings = SerializationSettings { encoding: SerializationEncoding::MsgPack, .. }; Defensive patterns
Strategy: validation
Validate before calling
// Rust: validate encoding before configuring the Redis cache
fn supports_cache_encoding(e: SerializationEncoding) -> bool {
matches!(e, SerializationEncoding::MsgPack | SerializationEncoding::Json)
}
assert!(supports_cache_encoding(settings.encoding), "Redis cache requires MsgPack or Json"); Type guard
fn is_cache_compatible(e: &SerializationEncoding) -> bool {
matches!(e, SerializationEncoding::MsgPack | SerializationEncoding::Json)
} Try / catch
match serialize_payload(&payload, &settings) {
Ok(bytes) => { /* store */ }
Err(e) if e.to_string().contains("not supported for Redis cache") => {
return Err(anyhow::anyhow!("config error: use MsgPack/Json for Redis cache"));
}
Err(e) => return Err(e.into()),
} Prevention
- Configure Redis cache clients with MsgPack or Json only.
- Do not share a single SerializationSettings across SBE message-bus clients and the Redis cache.
- Validate the encoding setting at client construction, not at first write.
- Check the SerializationEncoding enum arms in serialize_payload before choosing an encoding.
When it happens
Trigger: Calling serialize_payload (or the cache/query function that takes a SerializationSetting/SerializationEncoding) with SerializationEncoding::Sbe — e.g. a RedisCacheDatabase configured with an SBE serialization setting.
Common situations: Reusing a serialization config from a different integration (message bus / other backends do support SBE) when setting up the Redis cache; copy-pasted config where serialization setting is shared between clients.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Cap'n Proto encoding is not supported for Redis cache payloa
- SBE decoding requires the `sbe` feature
- failed to decode SBE {type_name}: {e}
- CustomData serialization failed: {e}
- Cannot persist position with no events: {}
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/3879152da21df878.
Report an issue: GitHub.