{"record":{"id":"94bbef380b2991ee","repo":"vectordotdev/vector","slug":"component-names-must-be-lowercase-and-contain-onl","errorCode":null,"errorMessage":"component names must be lowercase, and contain only letters, numbers, and underscores (e.g. \"{component_name_converted}\")","messagePattern":"component names must be lowercase, and contain only letters, numbers, and underscores \\(e\\.g\\. \"(.+?)\"\\)","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"lib/vector-config-macros/src/component_name.rs","lineNumber":155,"sourceCode":"            ),\n        ));\n    }\n\n    // Now try and parse the helper attribute as a literal string, which is the only valid form.\n    // After that, make sure it's actually valid according to our naming rules.\n    attr.parse_args::<LitStr>()\n        .map_err(|_| {\n            Error::new(\n                attr.span(),\n                format!(\n                    \"expected a string literal for the {component_type} name (i.e. `{component_type_attr}(\\\"...\\\")`)\"\n                ),\n            )\n        })\n        .and_then(|component_name| {\n            let component_name_str = component_name.value();\n            check_component_name_validity(&component_name_str)\n                .map_err(|e| Error::new(component_name.span(), e))\n                .map(|()| Some(component_name_str))\n        })\n}\n\nfn check_component_name_validity(component_name: &str) -> Result<(), String> {\n    // In a nutshell, component names must contain only lowercase ASCII alphabetic characters, or\n    // numbers, or underscores.\n\n    if component_name.is_empty() {\n        return Err(\"component name must be non-empty\".to_string());\n    }\n\n    // We only support ASCII names, so get that out of the way.\n    if !component_name.is_ascii() {\n        return Err(\"component names may only contain ASCII characters\".to_string());\n    }\n\n    // Now, we blindly try and convert the given component name into the correct format, and","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/vectordotdev/vector/blob/3708c39b12a93212ed8b8d7510b4cc7769cb5864/lib/vector-config-macros/src/component_name.rs#L137-L173","documentation":"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.","triggerScenarios":"`#[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.","commonSituations":"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.","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"],"exampleFix":"// before\n#[configurable_component(source(\"my-Source\"))]\n\n// after\n#[configurable_component(source(\"my_source\"))]","handlingStrategy":"validation","validationCode":"// Optional pre-commit check: name must be lowercase snake_case ASCII\nfn valid_component_name(name: &str) -> bool {\n    !name.is_empty()\n        && name.is_ascii()\n        && name\n            .chars()\n            .all(|c| c.is_ascii_lowercase() || c.is_ascii_digit() || c == '_')\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["rust","proc-macro","compile-time","naming-convention","vector"],"backgroundTag":"naming-convention-violation","analyzedSha":"3708c39b12a93212ed8b8d7510b4cc7769cb5864","analyzedAt":"2026-08-20T07:02:18.786Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}