{"record":{"id":"aab728af78d3a67b","repo":"nautechsystems/nautilus_trader","slug":"missing-broker-client-order-id-signal","errorCode":null,"errorMessage":"missing broker client order ID signal","messagePattern":"missing broker client order ID signal","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/common/encoder.rs","lineNumber":235,"sourceCode":"/// Returns an error if the broker-prefixed encoding is malformed or the\n/// decoded client order ID is invalid.\npub(crate) fn decode_client_order_id(\n    encoded: &str,\n    broker_id: &str,\n) -> 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))","sourceCodeStart":217,"sourceCodeEnd":253,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/common/encoder.rs#L217-L253","documentation":"Binance order IDs are round-tripped through a compact encoding: an optional broker prefix followed by a one-byte 'signal' byte identifying the payload format (hyphenated UUID, non-hyphenated, etc.). decode_broker_id_checked found the prefix but then hit an empty payload — no signal byte at all — so it cannot determine the format and bails.","triggerScenarios":"Calling decode_broker_id or decode_client_order_id on a string that consists of exactly the broker prefix (e.g. \"x-NAU-\") with nothing after it — typically a truncated or corrupted order ID, often after the exchange truncated a long newClientOrderId on the wire.","commonSituations":"Binance truncating client order IDs that exceed its length limit, cutting off the encoded payload; hand-editing or logging/marshalling bugs that clip the ID string; using an ID produced by a different encoder version.","solutions":["Check the original order ID for truncation — Binance caps newClientOrderId length; ensure encoded IDs fit within the limit before submitting.","Regenerate the order ID with the encoder and resubmit; do not attempt to decode the corrupted value.","Guard decode calls with a length check (payload after prefix must be >= 1 byte) to give a clearer failure upstream.","Verify the ID was produced by this adapter's encoder and not mixed with IDs from another integration."],"exampleFix":"// before\nlet Some((&signal, data)) = payload.as_bytes().split_first() else {\n    anyhow::bail!(\"missing broker client order ID signal\");\n};\n// after: validate length at encode time so this cannot occur\nanyhow::ensure!(\n    encoded.len() <= MAX_BINANCE_CLIENT_ORDER_ID_LEN,\n    \"encoded client order ID exceeds Binance limit: {}\",\n    encoded.len()\n);","handlingStrategy":"validation","validationCode":"fn is_decodable_broker_id(id: &str, prefix: &str) -> bool {\n    id.strip_prefix(prefix).map_or(false, |p| !p.is_empty())\n}","typeGuard":null,"tryCatchPattern":"match decode_client_order_id(&encoded) {\n    Ok(id) => id,\n    Err(e) if e.to_string().contains(\"missing broker client order ID signal\") => {\n        eprintln!(\"order ID truncated: {encoded}\");\n        encoded.to_string()\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Keep encoded client order IDs within Binance's newClientOrderId length cap so nothing is truncated.","Never hand-assemble prefixed IDs; always go through the encoder.","Log full IDs before sending so truncation can be diagnosed after the fact."],"tags":["binance","order-id","encoding","decoding","rust"],"backgroundTag":"invalid-identifier-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"}