nautechsystems/nautilus_trader · error

Failed to build BybitOpenOrdersParams

Error message

Failed to build BybitOpenOrdersParams

What it means

This panic comes from an `expect` on the derive_builder-generated `build()` for `BybitOpenOrdersParams` in `get_open_orders`. `build()` returns `Err` only when a field without a default (here `category: BybitProductType`) was never set on the builder. The library treats that as an impossible internal state and panics rather than returning an error.

Source

Thrown at crates/adapters/bybit/src/http/client.rs:891

        if let Some(oo) = open_only {
            builder.open_only(oo);
        }

        if let Some(of) = order_filter {
            builder.order_filter(of);
        }

        if let Some(l) = limit {
            builder.limit(l);
        }

        if let Some(c) = cursor {
            builder.cursor(c);
        }

        let params = builder
            .build()
            .expect("Failed to build BybitOpenOrdersParams");

        self.send_request(Method::GET, BYBIT_ORDER_REALTIME, Some(&params), None, true)
            .await
    }

    /// Places a new order (requires authentication).
    ///
    /// # Errors
    ///
    /// Returns an error if the request fails or the response cannot be parsed.
    ///
    /// # References
    ///
    /// - <https://bybit-exchange.github.io/docs/v5/order/create-order>
    pub async fn place_order(
        &self,
        request: &serde_json::Value,
    ) -> Result<BybitPlaceOrderResponse, BybitHttpError> {

View on GitHub (pinned to 18893faf8b)

Solutions

  1. If using the builder directly, call `.category(BybitProductType::...)` before `.build()`
  2. Replace `.expect(...)` with `?`/proper error mapping so a missing required field surfaces as `BybitHttpError` instead of a panic
  3. Check that you are calling the public `get_open_orders` with a valid `category` argument rather than the raw builder path
  4. Report the panic as a bug if it reproduces via the public `get_open_orders` API

Example fix

// before
let params = builder.build().expect("Failed to build BybitOpenOrdersParams");
// after
let params = builder.build().map_err(BybitHttpError::InvalidParams)?;
Defensive patterns

Strategy: validation

Validate before calling

// Ensure the category argument is supplied before calling get_open_orders
assert!(matches!(category, BybitProductType::Spot | BybitProductType::Linear | BybitProductType::Inverse | BybitProductType::Option), "category is required");

Type guard

fn has_category(p: &BybitOpenOrdersParamsBuilder) -> bool { /* builder exposes category as required; validate at call site */ true }

Try / catch

// Rust: prefer the Result-returning API; if wrapping the raw builder:
let params = builder.build().map_err(|e| MyError::ParamsBuild(e.to_string()))?;

Prevention

When it happens

Trigger: Calling `get_open_orders` on the Bybit HTTP client when `builder.category(category)` was not applied — i.e. the internal call path omits the required `category`. In practice the public wrapper always sets it, so this panic indicates a library bug or a caller using the raw builder directly and forgetting `category`.

Common situations: Hand-constructing `BybitOpenOrdersParamsBuilder` in custom code without calling `.category(...)`; a refactor that drops the category assignment; using an older/newer mix of builder fields after an API change.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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