{"record":{"id":"0d89f6411c1bb4d9","repo":"nautechsystems/nautilus_trader","slug":"invalid-uuid-broker-client-order-id-payload-length","errorCode":null,"errorMessage":"invalid UUID broker client order ID payload length","messagePattern":"invalid UUID broker client order ID payload length","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/common/encoder.rs","lineNumber":248,"sourceCode":"    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(),\n                \"missing raw broker client order ID payload\"\n            );\n            Ok(raw.to_string())\n        }\n        _ => anyhow::bail!(\n            \"unknown broker client order ID signal byte '{}'\",\n            signal as char\n        ),","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/a4b06ed870971b5671d12754ea138a3ab99b1dec/crates/adapters/binance/src/common/encoder.rs#L230-L266","documentation":"Decoding a broker-prefixed client order ID whose signal byte marks the UUID-format payload: the base62 characters after the signal must be exactly UUID_B62_LEN long. A different length means the value cannot be decoded back into the original UUID-based ClientOrderId.","triggerScenarios":"A clientOrderId starting with broker prefix + UUID signal byte but whose payload length is not the fixed UUID base62 length - truncated IDs, foreign IDs colliding with the prefix, or an encoder/decoder version mismatch.","commonSituations":"Upgrading adapter versions that changed UUID packing; replaying orders created by an older build; user-defined IDs that begin with the configured prefix followed by a UUID signal character.","solutions":["Align encoder and decoder versions - orders written by an older adapter must be read by that version or treated as opaque","Choose a distinctive broker_id to avoid collisions with exchange- or user-generated IDs","Treat un-decodable IDs as raw values instead of failing the whole order update path"],"exampleFix":"// before\nlet cid = decode_broker_id_checked(encoded, broker_id)?;\n\n// after: fall back to treating the value as an opaque ID\nlet cid = decode_broker_id_checked(encoded, broker_id)\n    .map(ClientOrderId::new)\n    .unwrap_or_else(|_| ClientOrderId::new(encoded.to_string()));","handlingStrategy":"type-guard","validationCode":"fn is_valid_uuid_format(id: &str, prefix: &str, uuid_len: usize) -> bool {\n    match id.strip_prefix(prefix) {\n        Some(p) if !p.is_empty() => p[1..].len() == uuid_len,\n        _ => true,\n    }\n}","typeGuard":"fn looks_like_adapter_uuid_id(id: &str, prefix: &str, uuid_b62_len: usize) -> bool {\n    id.strip_prefix(prefix).is_some_and(|p| p.len() == 1 + uuid_b62_len)\n}","tryCatchPattern":"match decode_broker_id_checked(encoded, broker_id) {\n    Ok(decoded) => ClientOrderId::new_checked(decoded)?,\n    Err(e) => {\n        log::warn!(\"UUID-format decode failed for '{encoded}': {e}\");\n        ClientOrderId::new(encoded) // opaque fallback\n    }\n}","preventionTips":["Never mix adapter versions across the encode/decode lifecycle of the same orders","Use distinctive broker prefixes to rule out foreign-ID collisions","Log both the encoded and decoded forms when persisting so mismatches are diagnosable"],"tags":["binance","order-ids","client-order-id","uuid","encoding"],"backgroundTag":"identifier-decode-failed","analyzedSha":"a4b06ed870971b5671d12754ea138a3ab99b1dec","analyzedAt":"2026-08-16T22:54:50.089Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}