{"record":{"id":"688a4975bc2e465a","repo":"vectordotdev/vector","slug":"required-one-of-cannot-be-applied-to-a-serde-688a49","errorCode":null,"errorMessage":"`required_one_of` cannot be applied to a `#[serde(skip_deserializing)]` field; users cannot set its value","messagePattern":"`required_one_of` cannot be applied to a `#\\[serde\\(skip_deserializing\\)\\]` field; users cannot set its value","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"lib/vector-config-macros/src/configurable.rs","lineNumber":434,"sourceCode":"            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(),\n                    \"`required_one_of` requires the field to be optional; use `Option<T>` or add `#[serde(default)]`\",\n                )\n                .to_compile_error();\n            }\n            if field.skip_deserializing() {\n                return syn::Error::new(\n                    field.span(),\n                    \"`required_one_of` cannot be applied to a `#[serde(skip_deserializing)]` field; users cannot set its value\",\n                )\n                .to_compile_error();\n            }\n        }\n    }\n\n    // Collect required_one_of groups at macro-expansion time: group_name -> [serde field names].\n    let mut groups: std::collections::BTreeMap<String, Vec<String>> =\n        std::collections::BTreeMap::new();\n    for field in fields.iter().filter(|f| f.visible()) {\n        if let Some(group) = field.required_one_of() {\n            groups\n                .entry(group.to_string())\n                .or_default()\n                .push(field.name().to_string());\n        }","sourceCodeStart":416,"sourceCodeEnd":452,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/lib/vector-config-macros/src/configurable.rs#L416-L452","documentation":"The final check in the `required_one_of` validation: a field marked `#[serde(skip_deserializing)]` can never be set by user configuration, so including it in a `required_one_of` group would make the group unsatisfiable. The derive rejects the combination at compile time with this message.","triggerScenarios":"Combining `#[required_one_of]` with `#[serde(skip_deserializing)]` on a field of a struct using the configurable derive, then compiling.","commonSituations":"Hard-coding an internal-only field via `skip_deserializing` while a stale `required_one_of` attribute remains; excluding a field from user config during a security refactor but keeping old validation attributes.","solutions":["Remove `required_one_of` from the `skip_deserializing` field","Remove `#[serde(skip_deserializing)]` if the field should be user-configurable and part of the group","Move the constraint to other settable fields in the group"],"exampleFix":"// before\n#[configurable_component]\nstruct Config {\n  #[serde(skip_deserializing)]\n  #[required_one_of]\n  internal: Option<u32>,\n}\n// after\n#[configurable_component]\nstruct Config {\n  #[serde(skip_deserializing)]\n  internal: Option<u32>,\n}","handlingStrategy":"validation","validationCode":"if field_has_attr(field, \"required_one_of\") && serde_arg_is(field, \"skip_deserializing\") {\n    panic!(\"required_one_of on skip_deserializing field\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Strip validation attributes when marking a field skip_deserializing","Reserve required_one_of for fields users can actually set in config"],"tags":["rust","proc-macro","serde","config-validation"],"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"}