{"record":{"id":"d986611c1464fd9e","repo":"nautechsystems/nautilus_trader","slug":"invalid-o-format-broker-client-order-id-payload-le","errorCode":null,"errorMessage":"invalid O-format broker client order ID payload length","messagePattern":"invalid O-format broker client order ID payload length","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/common/encoder.rs","lineNumber":240,"sourceCode":") -> anyhow::Result<ClientOrderId> {\n    let decoded = decode_broker_id_checked(encoded, broker_id)?;\n    ClientOrderId::new_checked(decoded)\n        .with_context(|| format!(\"invalid Binance client order ID '{encoded}'\"))\n}\n\nfn decode_broker_id_checked(encoded: &str, broker_id: &str) -> anyhow::Result<String> {\n    let prefix = broker_prefix(broker_id);\n    let Some(payload) = encoded.strip_prefix(&prefix) else {\n        return Ok(encoded.to_string());\n    };\n\n    let Some((&signal, data)) = payload.as_bytes().split_first() else {\n        anyhow::bail!(\"missing broker client order ID signal\");\n    };\n\n    match signal {\n        SIGNAL_O_HYPHENS | SIGNAL_O_NO_HYPHENS => {\n            anyhow::ensure!(\n                data.len() == O_FORMAT_B62_LEN,\n                \"invalid O-format broker client order ID payload length\"\n            );\n            let packed = decode_base62(data).context(\"invalid O-format broker client order ID\")?;\n            Ok(unpack_o_format(packed, signal == SIGNAL_O_HYPHENS))\n        }\n        SIGNAL_UUID_HYPHENS | SIGNAL_UUID_NO_HYPHENS => {\n            anyhow::ensure!(\n                data.len() == UUID_B62_LEN,\n                \"invalid UUID broker client order ID payload length\"\n            );\n            let value = decode_base62(data).context(\"invalid UUID broker client order ID\")?;\n            Ok(format_uuid(value, signal == SIGNAL_UUID_HYPHENS))\n        }\n        SIGNAL_RAW => {\n            let raw = std::str::from_utf8(data).context(\"invalid raw broker client order ID\")?;\n            anyhow::ensure!(\n                !raw.is_empty(),","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/common/encoder.rs#L222-L258","documentation":"decode_broker_id_checked splits the broker client order ID payload into a one-byte signal and body. When the signal indicates the O-format (base62-packed, with or without hyphens), the remaining bytes must be exactly O_FORMAT_B62_LEN characters. This error means the payload length did not match that fixed size, so the payload is corrupt or was not produced by the matching encoder.","triggerScenarios":"Calling decode_broker_id or decode_client_order_id with a payload whose first byte is SIGNAL_O_HYPHENS or SIGNAL_O_NO_HYPHENS but whose remainder is longer or shorter than O_FORMAT_B62_LEN — e.g. a truncated or hand-modified broker order ID, an ID produced by a different adapter version, or an unencoded Binance client order ID passed to the decoder.","commonSituations":"Migrating between adapter versions where the O-format encoding length changed; manually constructing or copy-pasting broker IDs; exchange-side truncation of long client order IDs when relayed back on order reports.","solutions":["Re-encode the order ID with encode_o_format / the matching encoder from this crate instead of hand-building the payload.","Verify the payload is a complete broker ID emitted by this adapter version; regenerate it rather than trimming/padding.","Check that the full payload (signal byte + O_FORMAT_B62_LEN chars) was stored and passed — no truncation in the database or message queue.","If the ID came from the exchange, confirm the original client order ID format actually matched the adapter's O-format before encoding."],"exampleFix":"// before\nlet decoded = decode_client_order_id(truncated_payload)?;\n\n// after\nassert_eq!(truncated_payload.len(), 1 + O_FORMAT_B62_LEN);\nlet decoded = decode_client_order_id(truncated_payload)?;","handlingStrategy":"validation","validationCode":"const O_FORMAT_B62_LEN: usize = /* per crate */ 22;\nfn is_valid_o_payload(p: &[u8]) -> bool {\n    p.len() == 1 + O_FORMAT_B62_LEN\n        && matches!(p[0], SIGNAL_O_HYPHENS | SIGNAL_O_NO_HYPHENS)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always produce broker IDs via the crate's encoders, never by hand.","Store payloads as opaque bytes to avoid truncation in DB columns or queues.","Pin and match adapter versions between encoding and decoding services."],"tags":["binance","decoding","payload-length","order-id"],"backgroundTag":"invalid-argument-format","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}