{"record":{"id":"86fa7160883ca4d6","repo":"vectordotdev/vector","slug":"expected-a-string-literal-for-the-component-type","errorCode":null,"errorMessage":"expected a string literal for the {component_type} name (i.e. `{component_type_attr}(\"...\")`)","messagePattern":"expected a string literal for the (.+?) name \\(i\\.e\\. `(.+?)\\(\"\\.\\.\\.\"\\)`\\)","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"lib/vector-config-macros/src/component_name.rs","lineNumber":145,"sourceCode":"    let component_type = component_type_attr.replace('_', \" \");\n\n    // Make sure the attribute actually has inner tokens. If it doesn't, this means they forgot\n    // entirely to specify a component name, and we want to give back a meaningful error that looks\n    // correct when applied in the context of `#[configurable_component(...)]`.\n    if attr.meta.require_list().is_err() {\n        return Err(Error::new(\n            attr.span(),\n            format!(\n                \"{component_type}s must have a name specified (e.g. `{component_type_attr}(\\\"my_component\\\")`)\"\n            ),\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","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/vectordotdev/vector/blob/3708c39b12a93212ed8b8d7510b4cc7769cb5864/lib/vector-config-macros/src/component_name.rs#L127-L163","documentation":"Compile-time error from Vector's component-name derive (lib/vector-config-macros/src/component_name.rs). After `#[configurable_component(source)]` etc. is expanded into a helper attribute like `#[source_component(...)]`, the derive parses the parenthesized payload with `attr.parse_args::<LitStr>()`. If that parse fails, the payload is not exactly one string literal, and this error is emitted on the attribute span.","triggerScenarios":"Writing the component name unquoted: `#[configurable_component(source(my_source))]`; passing multiple tokens like `source(\"a\", \"b\")`; passing an expression, const, or macro call (e.g. `source(concat!(...))`) instead of a literal; leaving stray tokens like `source(\"name\" = )`.","commonSituations":"Contributors adding a new source/sink/transform/enrichment table who copy a sketch where the name was a bare identifier, or who try to build the name from a constant or `concat!` (proc macros only see tokens, so computed values cannot work).","solutions":["Quote the name: change `#[configurable_component(source(my_source))]` to `#[configurable_component(source(\"my_source\"))]`","Put exactly one string literal inside the parentheses — no second argument, no trailing tokens","Do not compute the name via consts or macros; hard-code the literal string"],"exampleFix":"// before\n#[configurable_component(source(my_source))]\nstruct MySource;\n\n// after\n#[configurable_component(source(\"my_source\"))]\nstruct MySource;","handlingStrategy":"validation","validationCode":"# CI gate: fail fast on malformed component attributes\ncargo check --workspace --all-targets","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always quote component names: #[configurable_component(source(\"my_source\"))]","Pass exactly one string literal inside the attribute parentheses","Run `cargo check` immediately after adding or editing configurable_component attributes"],"tags":["rust","proc-macro","compile-time","vector","component-registration"],"backgroundTag":"proc-macro-attribute-argument-invalid","analyzedSha":"3708c39b12a93212ed8b8d7510b4cc7769cb5864","analyzedAt":"2026-08-20T07:02:18.786Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}