vectordotdev/vector · error · syn::Error

`required_one_of` is not supported on tuple struct fields

Error message

`required_one_of` is not supported on tuple struct fields

What it means

Compile-time error from `build_tuple_struct_generate_schema_fn` in vector-config-macros. Tuple structs serialize as arrays, not objects with named keys, so a `oneOf`-over-field-names requirement has no meaning there. Any `required_one_of` on a tuple struct field is rejected before schema generation.

Source

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

                // That's kind of useless, and ends up as noise in the schema, so if we didn't have
                // any of our own unflattened properties, then steal the first flattened subschema
                // and swap our main schema for it before flattening things overall.
                if !had_unflatted_properties {
                    schema = flattened_subschemas.remove(0);
                }

                ::vector_config::schema::convert_to_flattened_schema(&mut schema, flattened_subschemas);
            }

            Ok(schema)
        }
    }
}

fn build_tuple_struct_generate_schema_fn(fields: &[Field<'_>]) -> proc_macro2::TokenStream {
    for field in fields.iter() {
        if field.required_one_of().is_some() {
            return syn::Error::new(
                field.span(),
                "`required_one_of` is not supported on tuple struct fields",
            )
            .to_compile_error();
        }
    }

    let mapped_fields = fields
        .iter()
        // Don't map this field if it's marked to be skipped for both serialization and deserialization.
        .filter(|field| field.visible())
        .map(generate_tuple_struct_field);

    quote! {
        fn generate_schema(schema_gen: &::std::cell::RefCell<::vector_config::schema::SchemaGenerator>) -> std::result::Result<::vector_config::schema::SchemaObject, ::vector_config::GenerateError> {
            let mut subschemas = ::std::collections::Vec::new();

            #(#mapped_fields)*

View on GitHub (pinned to 3708c39b12)

Solutions

  1. Convert the tuple struct to a named struct so fields have keys and required_one_of is expressible
  2. Or delete the required_one_of attribute — it cannot be honored on tuple structs

Example fix

// before
struct Config(#[configurable(required_one_of = ["a"])] Inner);

// after
struct Config {
    #[configurable(required_one_of = ["a", "b"])]
    inner: Option<Inner>,
}
Defensive patterns

Strategy: validation

Validate before calling

# CI gate: unsupported tuple-struct usage fails at compile time
cargo check --workspace --all-targets

Prevention

When it happens

Trigger: `#[derive(Configurable)]` on a tuple struct like `struct Config(A)` where the field (position 0) carries `#[configurable(required_one_of(...))]`.

Common situations: Moving an attribute block from a named struct to a tuple wrapper, or blanket-applying component attribute macros during a refactor.

Related errors


AI-assisted analysis of vectordotdev/vector@3708c39b12 (2026-08-20). Data as JSON: /api/errors/3db6fb6a0c4fb2aa. Report an issue: GitHub.