nautechsystems/nautilus_trader · info

non-zero

Error message

non-zero

What it means

This is a compile-time-constant sanity check: COINBASE_REST_QUOTA builds a governor Quota of 30 requests/second and asserts 30 is non-zero before passing it to Quota::per_second. Quota::per_second requires a NonZeroU32, so the constant is wrapped with NonZeroU32::new and unwrapped with expect. This panic can never fire in practice because 30 is a literal non-zero.

Source

Thrown at crates/adapters/coinbase/src/http/client.rs:95

            OrdersListResponse, ProductsResponse,
        },
        parse::{
            parse_account_state, parse_cfm_account_state, parse_cfm_margin_balances,
            parse_cfm_position_status_report, parse_fill_report, parse_instrument,
            parse_order_status_report,
        },
        query::{
            CancelOrdersRequest, CreateOrderRequest, EditOrderRequest, FillListQuery, LimitFok,
            LimitFokParams, LimitGtc, LimitGtcParams, LimitGtd, LimitGtdParams, MarketFok,
            MarketIoc, MarketParams, OrderConfiguration, OrderListQuery, StopLimitGtc,
            StopLimitGtcParams, StopLimitGtd, StopLimitGtdParams,
        },
    },
};

/// Default Coinbase Advanced Trade REST rate limit (30 requests per second).
pub static COINBASE_REST_QUOTA: LazyLock<Quota> = LazyLock::new(|| {
    Quota::per_second(NonZeroU32::new(30).expect("non-zero")).expect("valid constant")
});

/// Returns the default retry configuration for the Coinbase HTTP client.
#[must_use]
pub fn default_retry_config() -> RetryConfig {
    RetryConfig {
        max_retries: 3,
        initial_delay_ms: 100,
        max_delay_ms: 5_000,
        backoff_factor: 2.0,
        jitter_ms: 250,
        operation_timeout_ms: Some(60_000),
        immediate_first: false,
        max_elapsed_ms: Some(180_000),
    }
}

/// Returns the retry configuration for the Coinbase data client.

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Keep the constant non-zero; if throttling to zero is intended, disable the quota/guard instead of setting 0.
  2. Use Quota::per_second(NonZeroU32::MAX) style or a const assertion if you want the mistake caught at compile time.

Example fix

// before
Quota::per_second(NonZeroU32::new(0).expect("non-zero")) // panics at init
// after
Quota::per_second(NonZeroU32::new(30).expect("non-zero"))
Defensive patterns

Strategy: validation

Validate before calling

// Not applicable to library users; maintainers should keep the literal non-zero:
const REST_RPS: u32 = 30;
assert!(REST_RPS > 0);

Prevention

When it happens

Trigger: Only if the source constant 30 were changed to 0 and the code were executed for the first time (LazyLock initialization).

Common situations: Developers editing the rate-limit constant to throttle the client and accidentally setting it to 0 will hit this panic on first use of the quota.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


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