vectordotdev/vector · error · syn::Error

`required_one_of` cannot be applied to a…

Error message

`required_one_of` cannot be applied to a `#[serde(skip_deserializing)]` field; users cannot set its value

What it means

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.

Solutions

  1. Remove `required_one_of` from the `skip_deserializing` field
  2. Remove `#[serde(skip_deserializing)]` if the field should be user-configurable and part of the group
  3. Move the constraint to other settable fields in the group

Example fix

// before
#[configurable_component]
struct Config {
  #[serde(skip_deserializing)]
  #[required_one_of]
  internal: Option<u32>,
}
// after
#[configurable_component]
struct Config {
  #[serde(skip_deserializing)]
  internal: Option<u32>,
}
Defensive patterns

Strategy: validation

Validate before calling

if field_has_attr(field, "required_one_of") && serde_arg_is(field, "skip_deserializing") {
    panic!("required_one_of on skip_deserializing field");
}

Prevention

When it happens

Trigger: Combining `#[required_one_of]` with `#[serde(skip_deserializing)]` on a field of a struct using the configurable derive, then compiling.

Common situations: 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.

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


AI-assisted analysis of vectordotdev/vector@bdb87aeaa4 (2026-09-16). Data as JSON: /api/errors/688a4975bc2e465a. Report an issue: GitHub.

Appendix: source

Thrown at lib/vector-config-macros/src/configurable.rs:434

            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(),
                    "`required_one_of` requires the field to be optional; use `Option<T>` or add `#[serde(default)]`",
                )
                .to_compile_error();
            }
            if field.skip_deserializing() {
                return syn::Error::new(
                    field.span(),
                    "`required_one_of` cannot be applied to a `#[serde(skip_deserializing)]` field; users cannot set its value",
                )
                .to_compile_error();
            }
        }
    }

    // Collect required_one_of groups at macro-expansion time: group_name -> [serde field names].
    let mut groups: std::collections::BTreeMap<String, Vec<String>> =
        std::collections::BTreeMap::new();
    for field in fields.iter().filter(|f| f.visible()) {
        if let Some(group) = field.required_one_of() {
            groups
                .entry(group.to_string())
                .or_default()
                .push(field.name().to_string());
        }

View on GitHub (pinned to bdb87aeaa4)