{"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/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/src/sinks/util/buffer/metrics/normalize.rs#L136-L172","documentation":"MetricNormalizer::with_config panics when NormalizerConfig::validate() rejects the cache settings. The normalizer maintains a MetricSet whose cache parameters (e.g. cache_*, diff/decay windows) must be internally consistent; invalid values are treated as a programmer/config error rather than a runtime condition. The panic message carries the Debug-formatted validation error.","triggerScenarios":"Constructing a MetricNormalizer (directly or via a metrics sink like prometheus_exporter) with a NormalizerConfig whose settings fail validate() — e.g. cache duration zero/negative or out-of-range values set programmatically.","commonSituations":"Embedding Vector's metric normalization library in custom code with hand-built NormalizerConfig values; malformed sink options that parse into invalid numeric settings.","solutions":["Read the {e:?} payload to see which validation rule failed and correct the offending cache setting","Check the config values feeding NormalizerConfig (durations must be positive and within allowed bounds)","If driven by TOML/YAML config, fix the corresponding sink option and re-run vector validate"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"let config = NormalizerConfig { cache_duration: Duration::from_secs(60), ..Default::default() };\nconfig.validate().expect(\"normalizer cache settings must pass validation\");","typeGuard":null,"tryCatchPattern":"// If constructing programmatically, validate first instead of panicking:\nmatch config.validate() {\n    Ok(c) => MetricNormalizer::with_config(normalizer, c),\n    Err(e) => return Err(anyhow!(\"invalid normalizer settings: {e:?}\")),\n}","preventionTips":["Always run NormalizerConfig::validate() before with_config","Use Default::default() as the base and override individual fields","Keep cache durations positive and within documented bounds"],"tags":["rust","metrics","configuration","panic"],"backgroundTag":"invalid-config-value","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"}