{"record":{"id":"39172db71836cee4","repo":"vectordotdev/vector","slug":"static-non-zero-number-delay","errorCode":null,"errorMessage":"static non-zero number","messagePattern":"static non-zero number","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"info","filePath":"src/transforms/delay.rs","lineNumber":44,"sourceCode":"    /// Time to delay each event, in milliseconds.\n    #[serde_as(as = \"serde_with::DurationMilliSeconds<u64>\")]\n    #[configurable(metadata(docs::human_name = \"Delay in milliseconds\", docs::example = 200))]\n    delay_ms: Duration,\n\n    /// Limit for number of items in the delay queue.\n    #[serde(default = \"default_queue_capacity\")]\n    queue_capacity: NonZeroUsize,\n\n    /// Strategy to handle full queue capacity.\n    #[serde(default)]\n    overflow_strategy: OverflowStrategy,\n\n    /// Delay events in provided delay periods until the condition is met.\n    condition: Option<AnyCondition>,\n}\n\nconst fn default_queue_capacity() -> NonZeroUsize {\n    NonZeroUsize::new(500).expect(\"static non-zero number\")\n}\n\nimpl Default for DelayConfig {\n    fn default() -> Self {\n        Self {\n            delay_ms: Default::default(),\n            queue_capacity: default_queue_capacity(),\n            overflow_strategy: Default::default(),\n            condition: Default::default(),\n        }\n    }\n}\n\n/// Event handling behavior when delay queue is full.\n#[configurable_component]\n#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]\n#[serde(rename_all = \"snake_case\")]\npub enum OverflowStrategy {","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/src/transforms/delay.rs#L26-L62","documentation":"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.","triggerScenarios":"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.","commonSituations":"Code review or refactoring of delay.rs where someone might change 500; otherwise developers just see the expect and wonder if it can fire.","solutions":["No action needed; 500 is a valid non-zero constant.","If changing the default, always keep it > 0 (the field is NonZeroUsize precisely to reject zero).","Prefer handling zero explicitly via config validation rather than editing this literal to 0."],"exampleFix":"// before\nconst fn default_queue_capacity() -> NonZeroUsize {\n    NonZeroUsize::new(500).expect(\"static non-zero number\")\n}\n// after (unchanged semantics; keep any replacement literal non-zero)\nconst fn default_queue_capacity() -> NonZeroUsize {\n    NonZeroUsize::new(500).expect(\"static non-zero number\")\n}","handlingStrategy":"validation","validationCode":"assert!(500 > 0); // constant is provably non-zero; no runtime guard needed","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the default capacity literal strictly positive.","If configurability is needed, accept NonZeroUsize in config so zero is rejected at parse time.","Do not bypass the type by casting through usize."],"tags":["rust","const-fn","nonzero","delay-transform","default-value"],"backgroundTag":"internal-invariant-violation","analyzedSha":"bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013","analyzedAt":"2026-09-16T02:53:35.741Z","contentChangedAt":"2026-09-16T02:53:35.741Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}