nautechsystems/nautilus_trader · error · anyhow::Error

missing raw broker client order ID payload

Error message

missing raw broker client order ID payload

What it means

For SIGNAL_RAW payloads, decode_broker_id_checked interprets the remaining bytes as the raw broker ID string and rejects empty strings. This error means a raw-format payload was supplied with no actual ID content after the signal byte.

Solutions

  1. Ensure the order always carries a non-empty client order ID before it is encoded.
  2. Check the storage/serialization step did not drop or truncate the payload body.
  3. If the ID is genuinely unknown, handle the decode failure at the caller instead of decoding an empty payload.

Example fix

// before
let id = decode_broker_id(payload)?; // payload = [SIGNAL_RAW]

// after
if payload.len() > 1 {
    let id = decode_broker_id(payload)?;
} else {
    tracing::warn!("empty raw broker ID payload; skipping decode");
}
Defensive patterns

Strategy: type-guard

Validate before calling

fn has_raw_payload(p: &[u8]) -> bool {
    p.len() > 1 && p[0] == SIGNAL_RAW
}

Try / catch

// match on the error and skip/repair
match decode_broker_id(payload) {
    Ok(id) => id,
    Err(e) if e.to_string().contains("missing raw broker client order ID") => {
        tracing::warn!("empty raw broker ID; treating as unknown");
        String::new()
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Calling decode_broker_id or decode_client_order_id with a payload consisting of only the SIGNAL_RAW byte (or with an empty body) — e.g. the encoder stored an empty raw ID or the payload was stripped during storage/transport.

Common situations: An order was created with an empty client order ID and later decoded; serialization pipelines dropping empty payloads; copy-paste losing the ID portion.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


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

Appendix: source

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

        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
        ),
    }
}

fn build_encoded(prefix: &str, signal: u8, b62: &[u8]) -> String {
    let mut result = String::with_capacity(prefix.len() + 1 + b62.len());
    result.push_str(prefix);
    result.push(signal as char);
    // base62 output is always valid ASCII
    result.push_str(std::str::from_utf8(b62).expect("base62 is valid UTF-8"));

View on GitHub (pinned to 18893faf8b)