{"record":{"id":"34c2b7669298823d","repo":"vectordotdev/vector","slug":"component-type-s-must-have-a-name-specified-e-g","errorCode":null,"errorMessage":"{component_type}s must have a name specified (e.g. `{component_type_attr}(\"my_component\")`)","messagePattern":"(.+?)s must have a name specified \\(e\\.g\\. `(.+?)\\(\"my_component\"\\)`\\)","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"lib/vector-config-macros/src/component_name.rs","lineNumber":133,"sourceCode":"            attrs::SOURCE_COMPONENT,\n            attrs::TRANSFORM_COMPONENT,\n            attrs::SECRETS_COMPONENT,\n        ],\n    ) {\n        return Ok(None);\n    }\n\n    // Reconstruct the original attribute path (i.e. `source`) from our marker version of it (i.e.\n    // `source_component`), so that any error message we emit is contextually relevant.\n    let path_str = path_to_string(attr.path());\n    let component_type_attr = path_str.replace(\"_component\", \"\");\n    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        })","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/vectordotdev/vector/blob/3708c39b12a93212ed8b8d7510b4cc7769cb5864/lib/vector-config-macros/src/component_name.rs#L115-L151","documentation":"For the `#[configurable_component(...)]` helper attributes (marker forms like `source_component`, `sink_component`, `transform_component`), the macro rebuilds the user-facing attribute name and requires the attribute to be a list with inner tokens — `#[source(\"my_source\")]`. If the attribute has no list part at all (e.g. bare `#[source]`), this contextual compile error is returned, phrased with the reconstructed component type (\"sources must have a name specified...\"). It is the friendlier pre-check before arg parsing.","triggerScenarios":"Writing a component attribute without its parenthesized name: `#[source]` or `#[configurable_component(source)]` instead of `#[source(\"file\")]` / `#[configurable_component(source(\"file\"))]`. A non-list meta (key-value form `#[source = \"x\"]`) also fails `require_list` and lands here.","commonSituations":"New component authors forgetting the name string; IDE auto-complete inserting the bare attribute path; refactoring from older attribute syntax where the name lived elsewhere.","solutions":["Give the attribute its list form with a quoted literal name: `#[source(\"my_component\")]`.","Match the naming rules — a lowercase literal string (kebab/snake per the project's convention); anything non-literal produces the adjacent parse error.","Compare against an existing component's attribute block and mirror the shape."],"exampleFix":"// before\n#[configurable_component(source)]\nstruct FileSourceConfig;\n\n// after\n#[configurable_component(source(\"file\"))]\nstruct FileSourceConfig;","handlingStrategy":"validation","validationCode":"// Compile-time enforced; correct form is a list attribute with a string literal:\n// #[configurable_component(source(\"file\"))]\n// struct FileSourceConfig;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always write component attributes with the parenthesized name list: #[source(\"name\")].","When the error names a component type (e.g. 'sources'), the fix belongs in that attribute's parentheses."],"tags":["rust","proc-macro","compile-error","vector","component-metadata"],"backgroundTag":"missing-macro-attribute","analyzedSha":"3708c39b12a93212ed8b8d7510b4cc7769cb5864","analyzedAt":"2026-08-20T07:02:18.786Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}