{"record":{"id":"63dbb88639f7cef2","repo":"vectordotdev/vector","slug":"component-cannot-have-multiple-names-defined","errorCode":null,"errorMessage":"component cannot have multiple names defined","messagePattern":"component cannot have multiple names defined","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"lib/vector-config-macros/src/component_name.rs","lineNumber":82,"sourceCode":"            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! {\n        impl #impl_generics #ident #ty_generics #where_clause {\n            pub(super) const NAME: &'static str = #component_name;\n        }\n\n        impl #impl_generics ::vector_config::NamedComponent for #ident #ty_generics #where_clause {\n            fn get_component_name(&self) -> &'static str {\n                #component_name\n            }\n        }","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/lib/vector-config-macros/src/component_name.rs#L64-L100","documentation":"The `ComponentName` derive requires exactly one component name. After validating the collected names, it checks `component_names.len() > 1` and fails compilation when more than one helper attribute supplied a name. Ambiguous naming would make config parsing and the component registry non-deterministic, so it is rejected at compile time.","triggerScenarios":"Applying two or more `#[component_name(\"...\")]`-style helper attributes (or any recognized component-name attributes, e.g. source/sink/transform variants) to a single derived struct, then compiling.","commonSituations":"Copy-pasting an attribute from a similar component and leaving both; switching component kind but keeping the old attribute; macro expansion from another macro injecting an extra name attribute.","solutions":["Remove all but one `#[component_name(\"...\")]` attribute from the struct","Keep the attribute matching the component's actual kind (source/sink/transform) and delete the others","If inheritance from a wrapper macro is intended, remove the manual attribute and let the macro supply the name"],"exampleFix":"// before\n#[component_name(\"old_name\")]\n#[component_name(\"new_name\")]\nstruct MySourceConfig;\n// after\n#[component_name(\"new_name\")]\nstruct MySourceConfig;","handlingStrategy":"validation","validationCode":"grep -n '#\\[component_name(' my_component.rs  # must list exactly one line","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When renaming a component, replace the old attribute instead of adding a second one","Audit for duplicate helper attributes after macro-generated expansion changes"],"tags":["rust","proc-macro","component-config"],"backgroundTag":"conflicting-config-options","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"}