{"record":{"id":"a84bcd882796b328","repo":"vectordotdev/vector","slug":"required-one-of-is-not-supported-on-enum-variant","errorCode":null,"errorMessage":"`required_one_of` is not supported on enum variant fields","messagePattern":"`required_one_of` is not supported on enum variant fields","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"lib/vector-config-macros/src/configurable.rs","lineNumber":901,"sourceCode":"        .filter(|field| field.visible() && !field.flatten())\n        .map(|field| field.name().to_string())\n        .collect()\n}\n\nfn collision_sibling_keys(fields: &[Field<'_>], enclosing_tag: Option<&str>) -> Vec<String> {\n    let mut names = unflattened_serialized_names(fields);\n    if let Some(tag) = enclosing_tag {\n        names.push(tag.to_owned());\n    }\n    names\n}\n\nfn generate_named_enum_field(\n    field: &Field<'_>,\n    sibling_keys: &[String],\n) -> proc_macro2::TokenStream {\n    if field.required_one_of().is_some() {\n        return syn::Error::new(\n            field.span(),\n            \"`required_one_of` is not supported on enum variant fields\",\n        )\n        .to_compile_error();\n    }\n    let field_name = field.ident().expect(\"field should be named\");\n    let field_ty = field.ty();\n    let field_already_contained = format!(\n        \"schema properties already contained entry for `{field_name}`, this should not occur\"\n    );\n    let field_key = field.name().to_string();\n\n    let field_schema = generate_struct_field(field, sibling_keys);\n\n    // Fields that have no default value are inherently required.  Unlike fields on a normal\n    // struct, we can't derive a default value for an individual field because `serde`\n    // doesn't allow even specifying a default value for an enum overall, only structs.\n    let spanned_is_optional = quote_spanned! {field.span()=>","sourceCodeStart":883,"sourceCodeEnd":919,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/lib/vector-config-macros/src/configurable.rs#L883-L919","documentation":"When generating the schema for a named enum variant, `generate_named_enum_field` rejects `required_one_of` on variant fields. One-of semantics on enum variant fields are not supported in the generated config schema, so the macro produces a compile error.","triggerScenarios":"Declaring an enum with `#[configurable]` where a struct-like variant's named field is annotated with `required_one_of`.","commonSituations":"Trying to encode 'variant A requires one of fields x or y' inside an enum used as a config component; users attempt this when modeling mutually alternative config shapes.","solutions":["Remove `required_one_of` from the enum variant field.","Split the variant into multiple variants, each representing one of the alternatives.","Use a nested named struct (where `required_one_of` is supported) as the variant's payload type."],"exampleFix":"// before\n#[configurable]\nenum Source {\n    A { #[configurable(required_one_of = [\"x\"])] x: u64, y: u64 },\n}\n\n// after\n#[configurable]\nenum Source {\n    A(NestedOneOf),\n}","handlingStrategy":"validation","validationCode":"// ensure enum variant fields carry no required_one_of before applying #[configurable]","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Model alternatives as separate enum variants, not field-level one-of constraints.","Nest a named struct inside the variant when one-of is needed."],"tags":["rust","proc-macro","compile-time","enum"],"backgroundTag":"unsupported-operation","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"}