vectordotdev/vector · error · syn::Error
component names must be lowercase, and contain only letters,
Error message
component names must be lowercase, and contain only letters, numbers, and underscores (e.g. "{component_name_converted}") What it means
Compile-time validation error from `check_component_name_validity`. The macro converts the given name to the canonical form (lowercase; every non-alphanumeric ASCII char to `_`) and compares: if input != converted, the name had uppercase letters or illegal characters, and the converted form is shown as the suggested fix.
Source
Thrown at lib/vector-config-macros/src/component_name.rs:155
),
));
}
// Now try and parse the helper attribute as a literal string, which is the only valid form.
// After that, make sure it's actually valid according to our naming rules.
attr.parse_args::<LitStr>()
.map_err(|_| {
Error::new(
attr.span(),
format!(
"expected a string literal for the {component_type} name (i.e. `{component_type_attr}(\"...\")`)"
),
)
})
.and_then(|component_name| {
let component_name_str = component_name.value();
check_component_name_validity(&component_name_str)
.map_err(|e| Error::new(component_name.span(), e))
.map(|()| Some(component_name_str))
})
}
fn check_component_name_validity(component_name: &str) -> Result<(), String> {
// In a nutshell, component names must contain only lowercase ASCII alphabetic characters, or
// numbers, or underscores.
if component_name.is_empty() {
return Err("component name must be non-empty".to_string());
}
// We only support ASCII names, so get that out of the way.
if !component_name.is_ascii() {
return Err("component names may only contain ASCII characters".to_string());
}
// Now, we blindly try and convert the given component name into the correct format, andView on GitHub (pinned to 3708c39b12)
Solutions
- Use the exact suggestion in the error message, e.g. change `source("my-source")` to `source("my_source")`
- Lowercase everything and replace hyphens/dots/spaces with underscores
- Check the remaining rules: non-empty and ASCII-only
Example fix
// before
#[configurable_component(source("my-Source"))]
// after
#[configurable_component(source("my_source"))] Defensive patterns
Strategy: validation
Validate before calling
// Optional pre-commit check: name must be lowercase snake_case ASCII
fn valid_component_name(name: &str) -> bool {
!name.is_empty()
&& name.is_ascii()
&& name
.chars()
.all(|c| c.is_ascii_lowercase() || c.is_ascii_digit() || c == '_')
} Prevention
- Name components in snake_case from the start; the error's suggestion shows the canonical form
- Avoid display names, hyphens, and CamelCase in component attributes
When it happens
Trigger: `#[configurable_component(source("my-source"))]` (hyphen), `source("MySource")` (uppercase), `source("my.source")`, `source("my source")`, or any digit/underscore-legal name broken by punctuation or capitals.
Common situations: Naming a component after a display name (`"Kafka Logs"`) or a hyphenated marketing name (`"file-source"`) instead of the snake_case identifier Vector requires for schema keys and doc slugs.
Related errors
- expected a string literal for the {component_type} name (i.e
- component name must be non-empty
- component names may only contain ASCII characters
- `required_one_of` cannot be applied to a `#[serde(skip)]` fi
- `required_one_of` cannot be applied to a `#[serde(flatten)]`
AI-assisted analysis of vectordotdev/vector@3708c39b12 (2026-08-20).
Data as JSON: /api/errors/94bbef380b2991ee.
Report an issue: GitHub.