vectordotdev/vector · info

static non-zero number

Error message

static non-zero number

What it means

default_queue_capacity for the delay transform returns NonZeroUsize::new(500).expect("static non-zero number"). The literal 500 is always non-zero, so the expect is unreachable; it merely adapts a fallible constructor to a const fn. Like the dedupe default, this is a compile-time invariant, not a runtime failure mode.

Solutions

  1. No action needed; 500 is a valid non-zero constant.
  2. If changing the default, always keep it > 0 (the field is NonZeroUsize precisely to reject zero).
  3. Prefer handling zero explicitly via config validation rather than editing this literal to 0.

Example fix

// before
const fn default_queue_capacity() -> NonZeroUsize {
    NonZeroUsize::new(500).expect("static non-zero number")
}
// after (unchanged semantics; keep any replacement literal non-zero)
const fn default_queue_capacity() -> NonZeroUsize {
    NonZeroUsize::new(500).expect("static non-zero number")
}
Defensive patterns

Strategy: validation

Validate before calling

assert!(500 > 0); // constant is provably non-zero; no runtime guard needed

Prevention

When it happens

Trigger: Not triggerable at runtime; evaluated when DelayConfig defaults are built (serde default for queue_capacity). Only an edited literal of 0 would make it panic, and then on every use of the default config.

Common situations: Code review or refactoring of delay.rs where someone might change 500; otherwise developers just see the expect and wonder if it can fire.

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 vectordotdev/vector@bdb87aeaa4 (2026-09-16). Data as JSON: /api/errors/39172db71836cee4. Report an issue: GitHub.

Appendix: source

Thrown at src/transforms/delay.rs:44

    /// Time to delay each event, in milliseconds.
    #[serde_as(as = "serde_with::DurationMilliSeconds<u64>")]
    #[configurable(metadata(docs::human_name = "Delay in milliseconds", docs::example = 200))]
    delay_ms: Duration,

    /// Limit for number of items in the delay queue.
    #[serde(default = "default_queue_capacity")]
    queue_capacity: NonZeroUsize,

    /// Strategy to handle full queue capacity.
    #[serde(default)]
    overflow_strategy: OverflowStrategy,

    /// Delay events in provided delay periods until the condition is met.
    condition: Option<AnyCondition>,
}

const fn default_queue_capacity() -> NonZeroUsize {
    NonZeroUsize::new(500).expect("static non-zero number")
}

impl Default for DelayConfig {
    fn default() -> Self {
        Self {
            delay_ms: Default::default(),
            queue_capacity: default_queue_capacity(),
            overflow_strategy: Default::default(),
            condition: Default::default(),
        }
    }
}

/// Event handling behavior when delay queue is full.
#[configurable_component]
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum OverflowStrategy {

View on GitHub (pinned to bdb87aeaa4)