{"record":{"id":"e2ce076aa3962342","repo":"vectordotdev/vector","slug":"component-must-have-a-name-defined-e-g-compon","errorCode":null,"errorMessage":"component must have a name defined (e.g. `#[component_name(\"foobar\")]`)","messagePattern":"component must have a name defined \\(e\\.g\\. `#\\[component_name\\(\"foobar\"\\)\\]`\\)","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"lib/vector-config-macros/src/component_name.rs","lineNumber":73,"sourceCode":"                errors.push(e);\n                None\n            }\n        })\n        .collect::<Vec<_>>();\n\n    if !errors.is_empty() {\n        let mut main_error = errors.remove(0);\n        for error in errors.drain(..) {\n            main_error.combine(error);\n        }\n\n        return main_error.into_compile_error().into();\n    }\n\n    // Any component names we have now have been validated, so we just need to check and make sure\n    // we actually have one, and only one, and spit out the correct errors otherwise.\n    if component_names.is_empty() {\n        return Error::new(\n            ident.span(),\n            \"component must have a name defined (e.g. `#[component_name(\\\"foobar\\\")]`)\",\n        )\n        .into_compile_error()\n        .into();\n    }\n\n    if component_names.len() > 1 {\n        return Error::new(ident.span(), \"component cannot have multiple names defined\")\n            .into_compile_error()\n            .into();\n    }\n\n    let component_name = component_names.remove(0);\n\n    // We have a single, valid component name, so let's actually spit out our derive.\n    let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl();\n    let derived = quote! {","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/lib/vector-config-macros/src/component_name.rs#L55-L91","documentation":"The `ComponentName` derive in vector-config-macros collects component names from helper attributes like `#[component_name(\"...\")]` and requires exactly one. This compile error fires when none was found, meaning Vector cannot assign the component its registry/config name. It is the 'zero names' case of the derive's own validation.","triggerScenarios":"Deriving `ComponentName` (or `#[configurable_component]`-style macros that invoke it) on a struct without any `#[component_name(\"...\")]` helper attribute, or with all helper attributes stripped (e.g. behind a `#[cfg]` that is disabled).","commonSituations":"Adding the derive but forgetting the helper attribute; deleting the attribute during refactoring; attribute gated out by a feature flag so the count is zero on some builds.","solutions":["Add a single `#[component_name(\"my_component\")]` attribute to the struct","Check that the attribute is not inside a disabled `#[cfg(...)]` block","Ensure the attribute path matches the crate's expected helper attribute name exactly (no typo)"],"exampleFix":"// before\n#[derive(ComponentName)]\nstruct MySinkConfig;\n// after\n#[derive(ComponentName)]\n#[component_name(\"my_sink\")]\nstruct MySinkConfig;","handlingStrategy":"validation","validationCode":"// ensure exactly one #[component_name(\"...\")] helper exists before building\ngrep -c '#\\[component_name(' src/**/my_component.rs # must print 1","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always add the #[component_name(\"...\")] attribute in the same commit as the derive","Grep for the helper attribute count when copying component boilerplate","Avoid cfg-gating component-name attributes"],"tags":["rust","proc-macro","component-config"],"backgroundTag":"missing-required-config-field","analyzedSha":"bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013","analyzedAt":"2026-09-16T02:53:35.741Z","contentChangedAt":"2026-09-16T02:53:35.741Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}