{"record":{"id":"98f4ba2f55d5cde8","repo":"nautechsystems/nautilus_trader","slug":"cap-n-proto-decoding-requires-the-capnp-feature","errorCode":null,"errorMessage":"Cap'n Proto decoding requires the `capnp` feature","messagePattern":"Cap'n Proto decoding requires the `capnp` feature","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/common/src/msgbus/external/codec/capnp_unavailable.rs","lineNumber":30,"sourceCode":"//  See the License for the specific language governing permissions and\n//  limitations under the License.\n// -------------------------------------------------------------------------------------------------\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};\n\nuse super::PayloadCodecError;\nuse crate::msgbus::BusPayloadType;\n\nmacro_rules! define_deserializer {\n    ($fn_name:ident, $ty:ty) => {\n        pub(crate) fn $fn_name(_payload: &[u8]) -> anyhow::Result<$ty> {\n            anyhow::bail!(\"Cap'n Proto decoding requires the `capnp` feature\")\n        }\n    };\n}\n\ndefine_deserializer!(deserialize_order_book_deltas, OrderBookDeltas);\ndefine_deserializer!(deserialize_order_book_depth10, OrderBookDepth10);\ndefine_deserializer!(deserialize_quote, QuoteTick);\ndefine_deserializer!(deserialize_trade, TradeTick);\ndefine_deserializer!(deserialize_bar, Bar);\ndefine_deserializer!(deserialize_mark_price, MarkPriceUpdate);\ndefine_deserializer!(deserialize_index_price, IndexPriceUpdate);\ndefine_deserializer!(deserialize_funding_rate, FundingRateUpdate);\ndefine_deserializer!(deserialize_option_greeks, OptionGreeks);\n\npub(super) fn serialize_payload(\n    payload_type: BusPayloadType,\n    _message: &dyn Any,\n) -> Result<Bytes, PayloadCodecError> {","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/common/src/msgbus/external/codec/capnp_unavailable.rs#L12-L48","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before (Cargo.toml)\nnautilus-common = \"0.x\"\n// after\nnautilus-common = { version = \"0.x\", features = [\"capnp\"] }","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"let deltas = match decode_deltas(payload) {\n    Ok(d) => d,\n    Err(e) if e.to_string().contains(\"capnp\") => {\n        eprintln!(\"capnp codec unavailable; use a JSON/msgpack publisher or rebuild with --features capnp\");\n        return Err(e);\n    }\n    Err(e) => return Err(e),\n};","preventionTips":["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."],"tags":["serialization","capnp","feature-gate","rust"],"backgroundTag":"feature-not-enabled","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"}