vectordotdev/vector · error · syn::Error
`required_one_of` cannot be applied to a `#[serde(skip)]`…
Error message
`required_one_of` cannot be applied to a `#[serde(skip)]` field
What it means
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.
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
Example fix
// before
#[configurable_component]
struct Config {
#[serde(skip)]
#[required_one_of]
a: u32,
b: u32,
}
// after
#[configurable_component]
struct Config {
#[required_one_of]
a: Option<u32>,
#[required_one_of]
b: Option<u32>,
} Defensive patterns
Strategy: validation
Validate before calling
// never combine required_one_of with serde(skip)
if field_has_attr(field, "required_one_of") && field_has_attr(field, "serde") && serde_arg_is(field, "skip") {
panic!("required_one_of on skipped field");
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.
Related errors
- `required_one_of` cannot be applied to a…
- enums must always have a tagging mode
- named struct fields must always have an ident
- `required_one_of` cannot be applied to a…
- `required_one_of` is not supported on newtype struct fields
AI-assisted analysis of vectordotdev/vector@bdb87aeaa4 (2026-09-16).
Data as JSON: /api/errors/62b4785637cd1da9.
Report an issue: GitHub.
Appendix: source
Thrown at lib/vector-config-macros/src/configurable.rs:410
quote! {
{
#field_schema
subschemas.push(subschema);
}
}
}
fn build_named_struct_generate_schema_fn(
container: &Container<'_>,
fields: &[Field<'_>],
) -> proc_macro2::TokenStream {
// Validate required_one_of usage before building groups.
// Scan ALL fields (including non-visible) so #[serde(skip)] fields are caught too.
for field in fields.iter() {
if field.required_one_of().is_some() {
if !field.visible() {
return syn::Error::new(
field.span(),
"`required_one_of` cannot be applied to a `#[serde(skip)]` field",
)
.to_compile_error();
}
if field.flatten() {
return syn::Error::new(
field.span(),
"`required_one_of` cannot be applied to a `#[serde(flatten)]` field",
)
.to_compile_error();
}
if !is_option_type(field.ty())
&& field.default_value().is_none()
&& container.default_value().is_none()
{
return syn::Error::new(
field.span(),View on GitHub (pinned to bdb87aeaa4)