vectordotdev/vector · error · syn::Error

component names may only contain ASCII characters

Error message

component names may only contain ASCII characters

What it means

Compile-time validation error from `check_component_name_validity`. After the non-empty check, `component_name.is_ascii()` is enforced because the name is embedded into generated code, JSON schemas, and documentation slugs that only handle ASCII.

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. Rename the component using only ASCII letters, digits, and underscores (e.g. `source("cafe")`, `source("logs")`)
  2. Check for invisible Unicode (non-breaking spaces, zero-width chars) if the name looks ASCII but still fails

Example fix

// before
#[configurable_component(source("café"))]

// after
#[configurable_component(source("cafe"))]
Defensive patterns

Strategy: validation

Validate before calling

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

Prevention

When it happens

Trigger: Naming a component with non-ASCII characters: `#[configurable_component(source("café"))]`, `source("日志")`, `sink("métricas")`, or names containing typographic dashes/spaces copied from prose.

Common situations: Non-English teams naming components in their native language, or smart quotes/dashes pasted from a document editor replacing ASCII ones.

Related errors


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