nautechsystems/nautilus_trader · error · anyhow::Error

invalid UUID broker client order ID payload length

Error message

invalid UUID broker client order ID payload length

What it means

decode_broker_id_checked requires that UUID-format broker client order ID payloads (signal SIGNAL_UUID_HYPHENS or SIGNAL_UUID_NO_HYPHENS) carry exactly UUID_B62_LEN base62 characters after the signal byte. This error indicates the body length is wrong, so the payload cannot be a valid packed UUID produced by the encoder.

Solutions

  1. Regenerate the broker ID using the crate's UUID encoder so the payload has the exact expected length.
  2. Confirm no upstream system (exchange, database, log pipeline) truncated or padded the stored broker ID.
  3. Decode with the adapter version that matches the encoder that produced the payload.
  4. If you have the original UUID, re-encode it rather than trying to repair the damaged payload.
Defensive patterns

Strategy: validation

Validate before calling

const UUID_B62_LEN: usize = /* per crate */ 22;
fn is_valid_uuid_payload(p: &[u8]) -> bool {
    p.len() == 1 + UUID_B62_LEN
        && matches!(p[0], SIGNAL_UUID_HYPHENS | SIGNAL_UUID_NO_HYPHENS)
}

Prevention

When it happens

Trigger: Calling decode_broker_id / decode_client_order_id with a UUID-signal payload whose data portion is not UUID_B62_LEN characters — truncated payloads, manually crafted IDs, or IDs encoded by an incompatible encoder version.

Common situations: Broker IDs truncated by exchange field limits or logging; hand-editing stored order IDs; mixing payloads from adapter versions with different UUID packing; passing plain UUID strings without the encoder wrapper.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/0d89f6411c1bb4d9. Report an issue: GitHub.

Appendix: source

Thrown at crates/adapters/binance/src/common/encoder.rs:248

    let Some(payload) = encoded.strip_prefix(&prefix) else {
        return Ok(encoded.to_string());
    };

    let Some((&signal, data)) = payload.as_bytes().split_first() else {
        anyhow::bail!("missing broker client order ID signal");
    };

    match signal {
        SIGNAL_O_HYPHENS | SIGNAL_O_NO_HYPHENS => {
            anyhow::ensure!(
                data.len() == O_FORMAT_B62_LEN,
                "invalid O-format broker client order ID payload length"
            );
            let packed = decode_base62(data).context("invalid O-format broker client order ID")?;
            Ok(unpack_o_format(packed, signal == SIGNAL_O_HYPHENS))
        }
        SIGNAL_UUID_HYPHENS | SIGNAL_UUID_NO_HYPHENS => {
            anyhow::ensure!(
                data.len() == UUID_B62_LEN,
                "invalid UUID broker client order ID payload length"
            );
            let value = decode_base62(data).context("invalid UUID broker client order ID")?;
            Ok(format_uuid(value, signal == SIGNAL_UUID_HYPHENS))
        }
        SIGNAL_RAW => {
            let raw = std::str::from_utf8(data).context("invalid raw broker client order ID")?;
            anyhow::ensure!(
                !raw.is_empty(),
                "missing raw broker client order ID payload"
            );
            Ok(raw.to_string())
        }
        _ => anyhow::bail!(
            "unknown broker client order ID signal byte '{}'",
            signal as char
        ),

View on GitHub (pinned to 18893faf8b)