nautechsystems/nautilus_trader · error · anyhow::Error
Cap'n Proto decoding requires the `capnp` feature
Error message
Cap'n Proto decoding requires the `capnp` feature
What it means
This module is a compile-time placeholder used when the crate is built without the `capnp` feature. Every generated Cap'n Proto deserializer stub unconditionally fails with this error, because decoding Cap'n Proto payloads requires the feature-gated implementation.
Source
Thrown at crates/common/src/msgbus/external/codec/capnp_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!("Cap'n Proto decoding requires the `capnp` 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
- Rebuild with the `capnp` feature enabled, e.g. `cargo build --features capnp` (or add it to your Cargo.toml dependency features list).
- If capnp cannot be enabled, switch the external sender/publisher to a supported codec (e.g. JSON/msgpack) so payloads match the built features.
- Verify at startup which codecs the binary supports and reject capnp stream configuration early.
- Check that your deployment pipeline preserves feature flags used in development builds.
Example fix
// before (Cargo.toml)
nautilus-common = "0.x"
// after
nautilus-common = { version = "0.x", features = ["capnp"] } Defensive patterns
Strategy: fallback
Try / catch
let deltas = match decode_deltas(payload) {
Ok(d) => d,
Err(e) if e.to_string().contains("capnp") => {
eprintln!("capnp codec unavailable; use a JSON/msgpack publisher or rebuild with --features capnp");
return Err(e);
}
Err(e) => return Err(e),
}; Prevention
- Enable the `capnp` feature in Cargo.toml if your data pipeline emits capnp payloads.
- Verify the payload codec configured on the external sender matches features compiled into the binary.
- Add a startup self-check that fails fast on codec/feature mismatches.
When it happens
Trigger: Receiving or decoding a Cap'n Proto-encoded external bus payload (order book deltas, depth10, etc.) while the crate was compiled without the `capnp` feature enabled.
Common situations: Installing a prebuilt package or default `cargo build` that omits non-default features, then connecting to an external sender that emits capnp-encoded payloads; feature flags dropped when switching from a source build to a packaged build.
Related errors
- failed to decode Cap'n Proto {}: {}
- Cap'n Proto encoding is not supported for Redis cache payloa
- Instances must have encode_record_batch_py method
- Failed to convert batched deltas to Python: {e}
- Failed to serialize config value: {e}
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/98f4ba2f55d5cde8.
Report an issue: GitHub.