nautechsystems/nautilus_trader · error

Failed to build BybitNoConvertRepayParams

Error message

Failed to build BybitNoConvertRepayParams

What it means

`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()`.

Source

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

    ///
    /// # References
    ///
    /// - <https://bybit-exchange.github.io/docs/v5/account/no-convert-repay>
    pub async fn no_convert_repay(
        &self,
        coin: &str,
        amount: Option<&str>,
    ) -> Result<BybitNoConvertRepayResponse, BybitHttpError> {
        let mut builder = BybitNoConvertRepayParamsBuilder::default();
        builder.coin(coin.to_string());

        if let Some(amt) = amount {
            builder.amount(amt.to_string());
        }

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

        if let Ok(params_json) = serde_json::to_string(&params) {
            log::debug!("Repay request params: {params_json}");
        }

        let body = serde_json::to_vec(&params)?;
        let result = self
            .send_request::<_, ()>(
                Method::POST,
                "/v5/account/no-convert-repay",
                None,
                Some(body),
                true,
            )
            .await;

        if let Err(ref e) = result
            && let Ok(params_json) = serde_json::to_string(&params)

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Ensure all required setters (coin, etc.) are called before `.build()`
  2. Replace the `expect` with `?` error propagation
  3. Re-verify the call site after any crate/Bybit API upgrade
  4. Report a bug if triggered through the public `no_convert_repay`

Example fix

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

Strategy: validation

Validate before calling

// coin is required for no_convert_repay; amount optional
assert!(!coin.is_empty(), "coin is required for repay");
if let Some(a) = amount { assert!(a.parse::<Decimal>().is_ok(), "amount must be decimal"); }

Try / catch

client.no_convert_repay(coin, amount).await.unwrap_or_else(|e| { log::error!("repay failed: {e}"); /* fallback: surface error */ });

Prevention

When it happens

Trigger: 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.

Common situations: Repay flows in custom code constructing the builder manually; upgrades where repay parameters became mandatory; dropped setter due to merge conflicts.

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/285f456f375a8295. Report an issue: GitHub.