{"record":{"id":"3db6fb6a0c4fb2aa","repo":"vectordotdev/vector","slug":"required-one-of-is-not-supported-on-tuple-struct","errorCode":null,"errorMessage":"`required_one_of` is not supported on tuple struct fields","messagePattern":"`required_one_of` is not supported on tuple struct fields","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"lib/vector-config-macros/src/configurable.rs","lineNumber":567,"sourceCode":"                // That's kind of useless, and ends up as noise in the schema, so if we didn't have\n                // any of our own unflattened properties, then steal the first flattened subschema\n                // and swap our main schema for it before flattening things overall.\n                if !had_unflatted_properties {\n                    schema = flattened_subschemas.remove(0);\n                }\n\n                ::vector_config::schema::convert_to_flattened_schema(&mut schema, flattened_subschemas);\n            }\n\n            Ok(schema)\n        }\n    }\n}\n\nfn build_tuple_struct_generate_schema_fn(fields: &[Field<'_>]) -> proc_macro2::TokenStream {\n    for field in fields.iter() {\n        if field.required_one_of().is_some() {\n            return syn::Error::new(\n                field.span(),\n                \"`required_one_of` is not supported on tuple struct fields\",\n            )\n            .to_compile_error();\n        }\n    }\n\n    let mapped_fields = fields\n        .iter()\n        // Don't map this field if it's marked to be skipped for both serialization and deserialization.\n        .filter(|field| field.visible())\n        .map(generate_tuple_struct_field);\n\n    quote! {\n        fn generate_schema(schema_gen: &::std::cell::RefCell<::vector_config::schema::SchemaGenerator>) -> std::result::Result<::vector_config::schema::SchemaObject, ::vector_config::GenerateError> {\n            let mut subschemas = ::std::collections::Vec::new();\n\n            #(#mapped_fields)*","sourceCodeStart":549,"sourceCodeEnd":585,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/lib/vector-config-macros/src/configurable.rs#L549-L585","documentation":"The `#[configurable]` derive macro rejects `required_one_of` on tuple struct fields. This attribute only makes sense for named struct fields, where the schema can express 'one of these named keys must be present'. For tuple structs the macro bails out at compile time with a syn::Error converted to a compile_error! token stream.","triggerScenarios":"Annotating a tuple struct (e.g. `struct Wrapper(u64);`) with `#[configurable]` while one of its positional fields carries `#[configurable(required_one_of = [...])]` or the struct-level equivalent that lands on fields.","commonSituations":"Copying a `required_one_of` annotation from a named config struct into a tuple/newtype wrapper, or applying the derive to an auto-generated tuple struct that inherited field attributes.","solutions":["Remove `required_one_of` from the tuple struct field.","Convert the tuple struct into a named struct if you genuinely need one-of semantics among fields.","Move `required_one_of` to an enum or a named struct variant that can express it in schema metadata."],"exampleFix":"// before\n#[configurable]\nstruct Foo(#[configurable(required_one_of = [\"a\"])] u64);\n\n// after\n#[configurable]\nstruct Foo {\n    #[configurable(required_one_of = [\"a\", \"b\"])]\n    value: u64,\n}","handlingStrategy":"validation","validationCode":"// compile-time: assert the struct is a named struct when using required_one_of\nstruct AssertNamedStruct;\nconst _: () = { let _ = AssertNamedStruct; }; // remove required_one_of from tuple fields","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only attach required_one_of to fields of named structs.","Never copy field attributes between tuple/newtype and named structs."],"tags":["rust","proc-macro","compile-time","schema"],"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"}