vectordotdev/vector · info
Fixed template
Error message
Fixed template
What it means
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.
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.
Example fix
// before
field: "field_name".try_into().expect("Fixed template"),
// after (only if literal might change; propagate instead of panic)
field: "field_name".try_into().expect("Fixed template"), // keep literal valid: no unbalanced {{ }} Defensive patterns
Strategy: validation
Validate before calling
// validate a template literal before editing generate_config let _: Template = "field_name".try_into()?; // must parse cleanly
Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
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
- UNSUPPORTED_DYNAMIC_FEATURE_SELECTOR
- a record with a next ID must have an event count
- a valid HTTP/1 URI is valid as an HTTP URI
- a validated HTTP endpoint is a valid `http 1` URI
- all json-file keys should be matched
AI-assisted analysis of vectordotdev/vector@bdb87aeaa4 (2026-09-16).
Data as JSON: /api/errors/52d1899b3a0dcb67.
Report an issue: GitHub.
Appendix: source
Thrown at src/transforms/log_to_metric.rs:182
const fn default_increment_by_value() -> bool {
false
}
const fn default_kind() -> MetricKind {
MetricKind::Incremental
}
#[derive(Debug, Clone)]
pub struct LogToMetric {
pub metrics: Vec<MetricConfig>,
pub all_metrics: bool,
}
impl GenerateConfig for LogToMetricConfig {
fn generate_config() -> serde_json::Value {
serde_json::to_value(Self {
metrics: Some(vec![MetricConfig {
field: "field_name".try_into().expect("Fixed template"),
name: None,
namespace: None,
tags: None,
metric: MetricTypeConfig::Counter(CounterConfig {
increment_by_value: false,
kind: MetricKind::Incremental,
}),
}]),
all_metrics: Some(true),
})
.unwrap()
}
}
#[async_trait::async_trait]
#[typetag::serde(name = "log_to_metric")]
impl TransformConfig for LogToMetricConfig {
async fn build(&self, _context: &TransformContext) -> crate::Result<Transform> {View on GitHub (pinned to bdb87aeaa4)