{"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":"anyhow::Error","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/a4b06ed870971b5671d12754ea138a3ab99b1dec/crates/adapters/binance/src/common/encoder.rs#L217-L253","documentation":"The Binance adapter packs NautilusTrader ClientOrderIds into Binance's clientOrderId as broker_id prefix + one signal byte + base62 payload. On decode, after stripping the configured broker prefix nothing remained, so there is no signal byte to dispatch on and the ID cannot be unpacked.","triggerScenarios":"A clientOrderId that is byte-for-byte identical to the broker prefix (e.g. a short/generic BinanceBrokerId with an ID that happens to equal it), or an ID truncated/corrupted down to just the prefix.","commonSituations":"Custom user-supplied client_order_id values that begin with or equal the broker prefix; a broker_id configured as a very short string so foreign exchange-generated IDs collide with it; IDs persisted externally and truncated to fit Binance's length cap.","solutions":["Configure a longer, distinctive BinanceBrokerId so exchange- or user-generated IDs never equal or start with the prefix","Do not hand-craft client_order_id values beginning with the broker prefix - let the adapter's encoder generate them","If decoding IDs stored externally, verify they were not truncated when saved to Binance (length limits apply)"],"exampleFix":"# before\nbroker_id = \"BNB\"          # short prefix, collisions likely\n\n# after\nbroker_id = \"NAUTILUS001\"  # distinctive prefix","handlingStrategy":"validation","validationCode":"fn is_decodable_broker_id(id: &str, prefix: &str) -> bool {\n    let Some(payload) = id.strip_prefix(prefix) else { return true }; // foreign IDs pass through\n    !payload.is_empty() // a signal byte must remain\n}","typeGuard":"fn broker_id_has_signal(id: &str, prefix: &str) -> bool {\n    id.strip_prefix(prefix).is_none_or(|p| !p.is_empty())\n}","tryCatchPattern":"let cid = match decode_broker_id_checked(encoded, broker_id) {\n    Ok(decoded) => ClientOrderId::new_checked(decoded)?,\n    Err(e) => {\n        log::warn!(\"treating '{encoded}' as opaque external ID: {e}\");\n        ClientOrderId::new(encoded)\n    }\n};","preventionTips":["Always set a distinctive, multi-character BinanceBrokerId in config","Generate client order IDs through the adapter, never by concatenating the prefix yourself","On decode failures, degrade to treating the value as an opaque external ID rather than dropping the order update"],"tags":["binance","order-ids","client-order-id","encoding","decode"],"backgroundTag":"identifier-decode-failed","analyzedSha":"a4b06ed870971b5671d12754ea138a3ab99b1dec","analyzedAt":"2026-08-16T22:54:50.089Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}