{"record":{"id":"52d1899b3a0dcb67","repo":"vectordotdev/vector","slug":"fixed-template","errorCode":null,"errorMessage":"Fixed template","messagePattern":"Fixed template","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"info","filePath":"src/transforms/log_to_metric.rs","lineNumber":182,"sourceCode":"const fn default_increment_by_value() -> bool {\n    false\n}\n\nconst fn default_kind() -> MetricKind {\n    MetricKind::Incremental\n}\n\n#[derive(Debug, Clone)]\npub struct LogToMetric {\n    pub metrics: Vec<MetricConfig>,\n    pub all_metrics: bool,\n}\n\nimpl GenerateConfig for LogToMetricConfig {\n    fn generate_config() -> serde_json::Value {\n        serde_json::to_value(Self {\n            metrics: Some(vec![MetricConfig {\n                field: \"field_name\".try_into().expect(\"Fixed template\"),\n                name: None,\n                namespace: None,\n                tags: None,\n                metric: MetricTypeConfig::Counter(CounterConfig {\n                    increment_by_value: false,\n                    kind: MetricKind::Incremental,\n                }),\n            }]),\n            all_metrics: Some(true),\n        })\n        .unwrap()\n    }\n}\n\n#[async_trait::async_trait]\n#[typetag::serde(name = \"log_to_metric\")]\nimpl TransformConfig for LogToMetricConfig {\n    async fn build(&self, _context: &TransformContext) -> crate::Result<Transform> {","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/src/transforms/log_to_metric.rs#L164-L200","documentation":"LogToMetricConfig::generate_config builds a sample config and converts the fixed template string \"field_name\" via try_into().expect(\"Fixed template\"). Template parsing only fails on invalid template syntax (e.g. unbalanced {{ }}), which the hard-coded literal cannot contain, so this expect is unreachable by design. It signals that a developer-introduced change to the literal broke the sample config generation.","triggerScenarios":"Only reachable if the string literal passed to try_into is edited to something that is not a valid Vector template (e.g. \"{{field\" with unbalanced delimiters); then any call to generate_config (used by `vector generate` and docs tooling) panics.","commonSituations":"Editing the generated sample config for log_to_metric and accidentally introducing invalid template syntax; users would see a panic when running config generation or docs checks.","solutions":["No action needed while the literal is a valid template.","If editing the literal, verify it parses as a template (balanced {{ }} delimiters) before committing.","Run `cargo vdev check` / config generation tests after changing generate_config to catch the panic in CI.","If a dynamic field name is needed, use Template::try_from(...)? and propagate the error instead of expect."],"exampleFix":"// before\nfield: \"field_name\".try_into().expect(\"Fixed template\"),\n// after (only if literal might change; propagate instead of panic)\nfield: \"field_name\".try_into().expect(\"Fixed template\"), // keep literal valid: no unbalanced {{ }}","handlingStrategy":"validation","validationCode":"// validate a template literal before editing generate_config\nlet _: Template = \"field_name\".try_into()?; // must parse cleanly","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat literals in generate_config as code: any edit must keep valid template syntax.","Run `cargo vdev check` / docs generation after touching generate_config.","Add a unit test asserting generate_config produces parseable component config.","Balance all {{ }} delimiters in template literals."],"tags":["rust","template","log-to-metric","generate-config","unreachable-panic"],"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"}