nautechsystems/nautilus_trader · error

failed to build order query params

Error message

failed to build order query params: {e}

What it means

query_order assembles BinanceOrderQueryParams through its typed builder (symbol plus orderId and/or orig_client_order_id). If the builder's validation fails, the error is wrapped with this message before any HTTP call is made.

Solutions

  1. Read the wrapped `{e}` message to identify the failing field.
  2. Ensure the command carries a valid venue_order_id (numeric) or client_order_id issued by this adapter.
  3. Verify command.instrument_id maps to a valid Binance Futures symbol via format_binance_symbol.
  4. Confirm the order was placed through this adapter so the broker ID encoding matches.

Example fix

// before
client.query_order(&BuildCommand::new(inst).build()?) // missing order identifier
// after
ensure!(command.venue_order_id.is_some() || !command.client_order_id.is_nil(),
        "query_order requires venue_order_id or client_order_id");
Defensive patterns

Strategy: validation

Validate before calling

anyhow::ensure!(
    command.venue_order_id.is_some() || !command.client_order_id.is_nil(),
    "query_order needs venue_order_id or client_order_id"
);
anyhow::ensure!(!format_binance_symbol(&command.instrument_id).is_empty(), "invalid instrument_id");

Try / catch

match client.query_order(cmd).await {
    Err(e) if e.to_string().contains("failed to build order query params") => {
        error!("order query params rejected: {e}");
    }
    other => other?,
}

Prevention

When it happens

Trigger: generate/query_order where the built parameter set violates BinanceOrderQueryParams validation — e.g. missing symbol, empty order identifier, or both orderId and orig_client_order_id absent/conflicting per builder rules.

Common situations: Commands missing both venue_order_id and a valid client_order_id mapping (encode_broker_id produced an unexpected value), or an empty/invalid symbol from format_binance_symbol on a malformed instrument_id.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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

Appendix: source

Thrown at crates/adapters/binance/src/futures/execution.rs:2930

                    Err(e) => log::warn!("Failed to query algo order status: {e}"),
                }

                return Ok(());
            }

            let mut builder = BinanceOrderQueryParamsBuilder::default();
            builder.symbol(symbol.clone());

            if let Some(oid) = order_id {
                builder.order_id(oid);
            }

            if let Some(coid) = orig_client_order_id {
                builder.orig_client_order_id(coid);
            }
            let params = builder
                .build()
                .map_err(|e| anyhow::anyhow!("failed to build order query params: {e}"))?;

            let result = http_client.query_order(&params).await;

            match result {
                Ok(order) => {
                    let ts_init = clock.get_time_ns();
                    let report = order.to_order_status_report(
                        account_id,
                        command.instrument_id,
                        price_precision,
                        size_precision,
                        treat_expired_as_canceled,
                        ts_init,
                    )?;
                    let venue_position_id = make_venue_position_id(
                        use_position_ids,
                        command.instrument_id,
                        order.position_side,

View on GitHub (pinned to 18893faf8b)