{"record":{"id":"285f456f375a8295","repo":"nautechsystems/nautilus_trader","slug":"failed-to-build-bybitnoconvertrepayparams","errorCode":null,"errorMessage":"Failed to build BybitNoConvertRepayParams","messagePattern":"Failed to build BybitNoConvertRepayParams","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/bybit/src/http/client.rs","lineNumber":1424,"sourceCode":"    ///\n    /// # References\n    ///\n    /// - <https://bybit-exchange.github.io/docs/v5/account/no-convert-repay>\n    pub async fn no_convert_repay(\n        &self,\n        coin: &str,\n        amount: Option<&str>,\n    ) -> Result<BybitNoConvertRepayResponse, BybitHttpError> {\n        let mut builder = BybitNoConvertRepayParamsBuilder::default();\n        builder.coin(coin.to_string());\n\n        if let Some(amt) = amount {\n            builder.amount(amt.to_string());\n        }\n\n        let params = builder\n            .build()\n            .expect(\"Failed to build BybitNoConvertRepayParams\");\n\n        if let Ok(params_json) = serde_json::to_string(&params) {\n            log::debug!(\"Repay request params: {params_json}\");\n        }\n\n        let body = serde_json::to_vec(&params)?;\n        let result = self\n            .send_request::<_, ()>(\n                Method::POST,\n                \"/v5/account/no-convert-repay\",\n                None,\n                Some(body),\n                true,\n            )\n            .await;\n\n        if let Err(ref e) = result\n            && let Ok(params_json) = serde_json::to_string(&params)","sourceCodeStart":1406,"sourceCodeEnd":1442,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/bybit/src/http/client.rs#L1406-L1442","documentation":"`no_convert_repay` builds `BybitNoConvertRepayParams` and panics through `expect` if `build()` errs — i.e. a required (no-default) field like coin was not set. Optional `amount` is conditionally set; the required fields must always be set before `build()`.","triggerScenarios":"The builder chain reaches `build()` without a required field set (e.g. coin omitted after a refactor), or the struct definition changes adding a new required field this call site does not set.","commonSituations":"Repay flows in custom code constructing the builder manually; upgrades where repay parameters became mandatory; dropped setter due to merge conflicts.","solutions":["Ensure all required setters (coin, etc.) are called before `.build()`","Replace the `expect` with `?` error propagation","Re-verify the call site after any crate/Bybit API upgrade","Report a bug if triggered through the public `no_convert_repay`"],"exampleFix":"// before\nlet params = builder.build().expect(\"Failed to build BybitNoConvertRepayParams\");\n// after\nlet params = builder.build().map_err(BybitHttpError::InvalidParams)?;","handlingStrategy":"validation","validationCode":"// coin is required for no_convert_repay; amount optional\nassert!(!coin.is_empty(), \"coin is required for repay\");\nif let Some(a) = amount { assert!(a.parse::<Decimal>().is_ok(), \"amount must be decimal\"); }","typeGuard":null,"tryCatchPattern":"client.no_convert_repay(coin, amount).await.unwrap_or_else(|e| { log::error!(\"repay failed: {e}\"); /* fallback: surface error */ });","preventionTips":["Always supply the coin argument","Validate optional amount before passing","Log params (as the client does) to catch missing fields early"],"tags":["panic","builder","repay","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"}