vectordotdev/vector · error · syn::Error

component name must be non-empty

Error message

component name must be non-empty

What it means

Compile-time validation error from `check_component_name_validity` in the component-name derive. An empty string literal parses fine as `LitStr`, but the first validity check rejects the empty name because the component name becomes the schema identifier, docs slug, and config key for the component.

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, and

View on GitHub (pinned to 3708c39b12)

Solutions

  1. Give the component a real name: `#[configurable_component(sink("my_sink"))]`
  2. Follow the naming rules while at it: lowercase ASCII letters, digits, underscores

Example fix

// before
#[configurable_component(sink(""))]
struct MySink;

// after
#[configurable_component(sink("my_sink"))]
struct MySink;
Defensive patterns

Strategy: validation

Validate before calling

# CI gate: empty names fail at compile time
cargo check --workspace --all-targets

Prevention

When it happens

Trigger: Declaring a component with an empty name literal: `#[configurable_component(sink(""))]` or `#[configurable_component(transform(""))]`.

Common situations: Skeleton code generated from a template with a placeholder name, or a copy-paste where the name was deleted before the attribute was updated.

Related errors


AI-assisted analysis of vectordotdev/vector@3708c39b12 (2026-08-20). Data as JSON: /api/errors/769912864b7b3b29. Report an issue: GitHub.