nautechsystems/nautilus_trader · info

checked above

Error message

checked above

What it means

In `await_class_ready`, the match arm `RateClass::Matching if instrument_name.is_some()` unwraps `instrument_name` with an `.expect("checked above")`. The guard makes the panic logically unreachable — it is a compiler-workaround unwrap, not a real failure mode.

Source

Thrown at crates/adapters/derive/src/common/rate_limit.rs:335

                Some(wait) => {
                    self.rollback_window(acquired, window);
                    self.clock.sleep(wait).await;
                }
            }
        }
    }

    /// Waits for the buckets a request class draws from, honoring the venue's
    /// per-instrument matching allowance when the request carries an
    /// instrument.
    pub(crate) async fn await_class_ready(
        &self,
        class: RateClass,
        instrument_name: Option<&Ustr>,
    ) -> u32 {
        match class {
            RateClass::Matching if instrument_name.is_some() => {
                let instrument = instrument_name.expect("checked above");
                self.await_buckets_ready(&[
                    RateBucket::Matching,
                    RateBucket::PerInstrument(instrument),
                ])
                .await
            }
            RateClass::Matching => self.await_buckets_ready(&[RateBucket::Matching]).await,
            RateClass::NonMatching => self.await_buckets_ready(&[RateBucket::NonMatching]).await,
            RateClass::CancelAll => self.await_buckets_ready(&[RateBucket::CancelAll]).await,
            RateClass::CancelByLabel => {
                self.await_buckets_ready(&[RateBucket::CancelByLabel]).await
            }
        }
    }

    /// Returns one consumed cell per key, but only while its cell still holds
    /// `window`. Once a cell moved to a later window, the stale consumption
    /// was already superseded and there is nothing to undo.

View on GitHub (pinned to 18893faf8b)

Solutions

  1. No user action needed — unreachable by construction.
  2. If you maintain the code, refactor to `if let Some(instrument) = instrument_name` to remove the unwrap entirely.

Example fix

// before
RateClass::Matching if instrument_name.is_some() => {
    let instrument = instrument_name.expect("checked above");
// after
RateClass::Matching => {
    let instrument = instrument_name.expect("checked above"); // or: if let Some(instrument)
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: Never, under correct code: the match guard guarantees `instrument_name` is `Some` before the expect runs. It would only fire if the guard and the expect were desynchronized by a future edit.

Common situations: Developers hitting this are almost certainly misreading the code; a real panic would require a Rust compiler bug or a refactor that separated the guard from the unwrap.

Related errors


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