{"record":{"id":"62b4785637cd1da9","repo":"vectordotdev/vector","slug":"required-one-of-cannot-be-applied-to-a-serde","errorCode":null,"errorMessage":"`required_one_of` cannot be applied to a `#[serde(skip)]` field","messagePattern":"`required_one_of` cannot be applied to a `#\\[serde\\(skip\\)\\]` field","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"lib/vector-config-macros/src/configurable.rs","lineNumber":410,"sourceCode":"\n    quote! {\n        {\n            #field_schema\n            subschemas.push(subschema);\n        }\n    }\n}\n\nfn build_named_struct_generate_schema_fn(\n    container: &Container<'_>,\n    fields: &[Field<'_>],\n) -> proc_macro2::TokenStream {\n    // Validate required_one_of usage before building groups.\n    // Scan ALL fields (including non-visible) so #[serde(skip)] fields are caught too.\n    for field in fields.iter() {\n        if field.required_one_of().is_some() {\n            if !field.visible() {\n                return syn::Error::new(\n                    field.span(),\n                    \"`required_one_of` cannot be applied to a `#[serde(skip)]` field\",\n                )\n                .to_compile_error();\n            }\n            if field.flatten() {\n                return syn::Error::new(\n                    field.span(),\n                    \"`required_one_of` cannot be applied to a `#[serde(flatten)]` field\",\n                )\n                .to_compile_error();\n            }\n            if !is_option_type(field.ty())\n                && field.default_value().is_none()\n                && container.default_value().is_none()\n            {\n                return syn::Error::new(\n                    field.span(),","sourceCodeStart":392,"sourceCodeEnd":428,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/lib/vector-config-macros/src/configurable.rs#L392-L428","documentation":"Before generating the JSON schema function for a named struct, the `Configurable` derive validates `required_one_of` usage. A field marked `#[serde(skip)]` is invisible to serde deserialization, so a `required_one_of` group referencing it could never be satisfied by user input; the derive rejects this combination at compile time. The scan deliberately includes non-visible fields to catch this.","triggerScenarios":"Annotating a field with both `required_one_of` and `#[serde(skip)]` (or `#[serde(skip_serializing)]` variants that make `field.visible()` false) on a struct using the configurable derive, then compiling.","commonSituations":"Skipping a field from output while still trying to include it in an at-least-one-of validation group; disabling a legacy field with `#[serde(skip)]` but leaving old validation attributes attached.","solutions":["Remove `required_one_of` from the skipped field, since users cannot set it","Remove the `#[serde(skip)]` if the field should actually participate in deserialization and validation","Move the `required_one_of` constraint to visible sibling fields that the group actually intends to require"],"exampleFix":"// before\n#[configurable_component]\nstruct Config {\n  #[serde(skip)]\n  #[required_one_of]\n  a: u32,\n  b: u32,\n}\n// after\n#[configurable_component]\nstruct Config {\n  #[required_one_of]\n  a: Option<u32>,\n  #[required_one_of]\n  b: Option<u32>,\n}","handlingStrategy":"validation","validationCode":"// never combine required_one_of with serde(skip)\nif field_has_attr(field, \"required_one_of\") && field_has_attr(field, \"serde\") && serde_arg_is(field, \"skip\") {\n    panic!(\"required_one_of on skipped field\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When adding #[serde(skip)] to a field, strip validation attributes from it in the same edit","Keep required_one_of groups limited to user-settable fields"],"tags":["rust","proc-macro","serde","schema"],"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"}