{"record":{"id":"82bec87884e9a296","repo":"vectordotdev/vector","slug":"invalid-cache-settings-e","errorCode":null,"errorMessage":"Invalid cache settings: {e:?}","messagePattern":"Invalid cache settings: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/sinks/util/buffer/metrics/normalize.rs","lineNumber":154,"sourceCode":"/// A self-contained metric normalizer.\n///\n/// The normalization state is stored internally, and it can only be created from a normalizer implementation that is\n/// either `Default` or is constructed ahead of time, so it is primarily useful for constructing a usable normalizer\n/// via implicit conversion methods or when no special parameters are required for configuring the underlying normalizer.\npub struct MetricNormalizer<N> {\n    state: MetricSet,\n    normalizer: N,\n}\n\nimpl<N> MetricNormalizer<N> {\n    /// Creates a new normalizer with the given configuration.\n    pub fn with_config<D: NormalizerSettings + Clone>(\n        normalizer: N,\n        config: NormalizerConfig<D>,\n    ) -> Self {\n        let settings = config\n            .validate()\n            .unwrap_or_else(|e| panic!(\"Invalid cache settings: {e:?}\"))\n            .into_settings();\n        Self {\n            state: MetricSet::new(settings),\n            normalizer,\n        }\n    }\n\n    /// Creates a new normalizer with a time-to-live policy.\n    pub fn with_ttl(normalizer: N, ttl: Duration) -> Self {\n        Self {\n            state: MetricSet::with_policies(None, Some(TtlPolicy::new(ttl))),\n            normalizer,\n        }\n    }\n\n    /// Gets a mutable reference to the current metric state for this normalizer.\n    pub const fn get_state_mut(&mut self) -> &mut MetricSet {\n        &mut self.state","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/vectordotdev/vector/blob/3708c39b12a93212ed8b8d7510b4cc7769cb5864/src/sinks/util/buffer/metrics/normalize.rs#L136-L172","documentation":"MetricNormalizer is the per-sink metrics cache/normalizer that tracks metric series before buffering. with_config runs NormalizerConfig::validate() and panics at component construction if any cache setting is explicitly zero: max_bytes = Some(0) (InvalidMaxBytes), max_events = Some(0) (InvalidMaxEvents), or time_to_live = Some(0) (InvalidTimeToLive). This is a fail-fast check: a degenerate cache is rejected at startup instead of mis-normalizing metrics at runtime.","triggerScenarios":"Constructing a metrics sink whose normalizer config contains max_bytes: 0, max_events: 0, or time_to_live: 0 (explicitly set values, not omitted ones); any code path that calls MetricNormalizer::with_config without pre-validating NormalizerConfig.","commonSituations":"Config generation that writes 0 as a placeholder, custom Vector builds deriving normalizer settings arithmetically from another buffer config, or version changes that remapped which sink option lands in these fields. Stock defaults (None falling back to the sink's NormalizerSettings) never trip this.","solutions":["Read the {e:?} payload in the panic - it names the exact offending field (max_bytes / max_events / time_to_live)","Set the offending field to a positive value or remove it so the sink's NormalizerSettings defaults apply","Run `vector validate <config>` on the config to catch it at check time instead of process start","If a stock Vector config produces zeros here, capture the config and open an issue - defaults must never resolve to 0"],"exampleFix":"// before\nlet normalizer = MetricNormalizer::with_config(inner, config); // panics if any field is Some(0)\n\n// after\nlet config = config.validate().map_err(|e| format!(\"invalid cache settings: {e:?}\"))?;\nlet normalizer = MetricNormalizer::with_config(inner, config);","handlingStrategy":"validation","validationCode":"let cfg = NormalizerConfig::<D> { max_bytes: Some(268_435_488), max_events: Some(500_000), time_to_live: Some(600), ..Default::default() };\nmatch cfg.validate() {\n    Ok(valid) => { let _ = MetricNormalizer::with_config(inner, valid); }\n    Err(e) => { /* reject the config with a proper error; do not construct */ }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never set normalizer cache sizes or TTL to 0; omit them to use sink defaults","Run `vector validate` on config changes in CI","When embedding MetricNormalizer, call NormalizerConfig::validate() before with_config and surface the error instead of letting it panic"],"tags":["rust","vector","metrics","sink","cache","panic","config-validation"],"backgroundTag":"invalid-cache-config","analyzedSha":"3708c39b12a93212ed8b8d7510b4cc7769cb5864","analyzedAt":"2026-08-20T07:02:18.786Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}