{"record":{"id":"526010055231653a","repo":"nautechsystems/nautilus_trader","slug":"wrong-schema-id-expected-crate-spot-sbe-spot","errorCode":null,"errorMessage":"Wrong schema ID: expected {crate::spot::sbe::spot::SBE_SCHEMA_ID}, received {schema_id}","messagePattern":"Wrong schema ID: expected (.+?), received (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/spot/websocket/trading/decode_sbe.rs","lineNumber":84,"sourceCode":"            data.len()\n        );\n    }\n\n    let buf = ReadBuf::new(data);\n    let block_length = buf.get_u16_at(0);\n    let template_id = buf.get_u16_at(2);\n    let schema_id = buf.get_u16_at(4);\n    let version = buf.get_u16_at(6);\n\n    if template_id != execution_report_event_codec::SBE_TEMPLATE_ID {\n        anyhow::bail!(\n            \"Wrong template ID: expected {}, received {template_id}\",\n            execution_report_event_codec::SBE_TEMPLATE_ID\n        );\n    }\n\n    if schema_id != crate::spot::sbe::spot::SBE_SCHEMA_ID {\n        anyhow::bail!(\n            \"Wrong schema ID: expected {}, received {schema_id}\",\n            crate::spot::sbe::spot::SBE_SCHEMA_ID\n        );\n    }\n\n    let min_block_len = execution_report_min_block_length(version);\n    if usize::from(block_length) < min_block_len {\n        anyhow::bail!(\n            \"SBE execution report block length too short: expected at least {min_block_len}, was {block_length}\"\n        );\n    }\n\n    let min_len = HEADER_LEN + usize::from(block_length);\n    if data.len() < min_len {\n        anyhow::bail!(\n            \"Buffer too short for fixed block: expected {min_len}, was {}\",\n            data.len()\n        );","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/spot/websocket/trading/decode_sbe.rs#L66-L102","documentation":"decode_execution_report checks the SBE header's schema ID against the crate's expected spot SBE schema ID. This error means the payload was encoded with a different schema version/definition than the codecs compiled into this adapter, so field layouts may be incompatible. The decoder refuses to interpret bytes it cannot safely map.","triggerScenarios":"Calling decode_execution_report with a frame whose header bytes 4-5 hold a schema ID differing from crate::spot::sbe::spot::SBE_SCHEMA_ID — e.g. a payload captured from an older/newer Binance SBE schema, or a test fixture built with mismatched schema constants.","commonSituations":"Binance publishing a new SBE schema revision while the adapter ships stale generated codecs; mixing captured binary fixtures from different schema eras in tests; proxying streams from another venue/product that uses a different schema ID.","solutions":["Update the adapter's generated SBE codecs to the schema version Binance currently serves","Re-encode or re-capture test fixtures with the schema version matching SBE_SCHEMA_ID","Confirm the payload comes from the Binance Spot SBE user-data stream, not another schema","Log the received schema ID and compare with the expected constant to identify the version drift"],"exampleFix":"// before\nlet report = decode_execution_report(old_captured_frame)?;\n// after\nlet schema_id = u16::from_be_bytes([old_captured_frame[4], old_captured_frame[5]]);\nanyhow::ensure!(schema_id == crate::spot::sbe::spot::SBE_SCHEMA_ID, \"re-capture fixture with current schema\");\nlet report = decode_execution_report(old_captured_frame)?;","handlingStrategy":"validation","validationCode":"pub fn has_expected_schema(data: &[u8]) -> bool {\n    data.len() >= 8\n        && u16::from_be_bytes([data[4], data[5]]) == crate::spot::sbe::spot::SBE_SCHEMA_ID\n}","typeGuard":"fn with_current_schema(data: &[u8]) -> Option<&[u8]> {\n    (data.len() >= 8\n        && u16::from_be_bytes([data[4], data[5]]) == crate::spot::sbe::spot::SBE_SCHEMA_ID)\n    .then_some(data)\n}","tryCatchPattern":"match decode_execution_report(&frame) {\n    Ok(r) => handle(r),\n    Err(e) if e.to_string().contains(\"Wrong schema ID\") => {\n        alert_schema_drain(&frame); // capture for codec regeneration\n    }\n    Err(e) => log::warn!(\"SBE decode failed: {e}\"),\n}","preventionTips":["Track Binance SBE schema announcements and regenerate codecs promptly","Reject or quarantine frames with unexpected schema IDs and sample them for diagnosis","Avoid replaying captured fixtures across schema versions","Version-stamp recorded fixtures with the schema they were captured under"],"tags":["sbe","binance","schema","version-mismatch"],"backgroundTag":"schema-validation-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"}