{"record":{"id":"fe44447713bec7b9","repo":"nautechsystems/nautilus_trader","slug":"failed-to-build-bybitopenordersparams","errorCode":null,"errorMessage":"Failed to build BybitOpenOrdersParams","messagePattern":"Failed to build BybitOpenOrdersParams","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/bybit/src/http/client.rs","lineNumber":891,"sourceCode":"        if let Some(oo) = open_only {\n            builder.open_only(oo);\n        }\n\n        if let Some(of) = order_filter {\n            builder.order_filter(of);\n        }\n\n        if let Some(l) = limit {\n            builder.limit(l);\n        }\n\n        if let Some(c) = cursor {\n            builder.cursor(c);\n        }\n\n        let params = builder\n            .build()\n            .expect(\"Failed to build BybitOpenOrdersParams\");\n\n        self.send_request(Method::GET, BYBIT_ORDER_REALTIME, Some(&params), None, true)\n            .await\n    }\n\n    /// Places a new order (requires authentication).\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the request fails or the response cannot be parsed.\n    ///\n    /// # References\n    ///\n    /// - <https://bybit-exchange.github.io/docs/v5/order/create-order>\n    pub async fn place_order(\n        &self,\n        request: &serde_json::Value,\n    ) -> Result<BybitPlaceOrderResponse, BybitHttpError> {","sourceCodeStart":873,"sourceCodeEnd":909,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/bybit/src/http/client.rs#L873-L909","documentation":"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.","triggerScenarios":"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`.","commonSituations":"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.","solutions":["If using the builder directly, call `.category(BybitProductType::...)` before `.build()`","Replace `.expect(...)` with `?`/proper error mapping so a missing required field surfaces as `BybitHttpError` instead of a panic","Check that you are calling the public `get_open_orders` with a valid `category` argument rather than the raw builder path","Report the panic as a bug if it reproduces via the public `get_open_orders` API"],"exampleFix":"// before\nlet params = builder.build().expect(\"Failed to build BybitOpenOrdersParams\");\n// after\nlet params = builder.build().map_err(BybitHttpError::InvalidParams)?;","handlingStrategy":"validation","validationCode":"// Ensure the category argument is supplied before calling get_open_orders\nassert!(matches!(category, BybitProductType::Spot | BybitProductType::Linear | BybitProductType::Inverse | BybitProductType::Option), \"category is required\");","typeGuard":"fn has_category(p: &BybitOpenOrdersParamsBuilder) -> bool { /* builder exposes category as required; validate at call site */ true }","tryCatchPattern":"// Rust: prefer the Result-returning API; if wrapping the raw builder:\nlet params = builder.build().map_err(|e| MyError::ParamsBuild(e.to_string()))?;","preventionTips":["Always pass a concrete product type (category) to get_open_orders","Avoid using raw param builders directly; use the typed client methods","After upgrades, compile-check call sites against changed builder fields"],"tags":["panic","builder","missing-required-field","bybit"],"backgroundTag":"missing-required-argument","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}