vectordotdev/vector · error

enums must always have a tagging mode

Error message

enums must always have a tagging mode

What it means

In the vector-config derive machinery, `is_enum_schema_potentially_ambiguous` unwraps `container.tagging()` with an expect. serde guarantees every enum container has a tagging mode (internal/adjacent/untagged/externally tagged), so None means the derive saw a container it classified as an enum without tagging metadata — a break of the derive's own invariants.

Solutions

  1. Ensure vector-config, vector-config-macros, and serde versions are consistent (update the workspace / cargo update)
  2. Rebuild cleanly (cargo clean) to rule out stale proc-macro artifacts
  3. If reproducible on a fresh build, file an issue with the enum definition and dependency versions
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: Running the `#[configurable]` derive on an enum when `build_enum_generate_schema_fn` inspects the container and `tagging()` returns None — only possible if the container data is malformed or the derive's container classification changed.

Common situations: Unreachable for users; could surface with a version mismatch between vector-config and serde/serde_derive, or a proc-macro bug after upgrading toolchain versions.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


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

Appendix: source

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

        }
    };

    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::vec::Vec::new();
            let mut discriminant_map = ::std::collections::HashMap::new();

            #(#mapped_variants)*

            #generate_block
        }
    }
}

fn is_enum_schema_potentially_ambiguous(container: &Container, variants: &[Variant]) -> bool {
    let tagging = container
        .tagging()
        .expect("enums must always have a tagging mode");
    match tagging {
        Tagging::None => {
            // Named variants are distinguished by required fields, while scalar and newtype
            // variants are distinguished by their generated schemas. `EnumDiscriminant` handles
            // both forms, so every multi-variant untagged enum can be checked for overlap.
            variants.len() >= 2
        }
        _ => {
            // Tagged enums can contain trailing `#[serde(untagged)]` variants. If there are
            // multiple such variants, collect their discriminants so overlapping fallbacks use
            // `anyOf`.
            variants
                .iter()
                .filter(|variant| variant.tagging() == &Tagging::None)
                .count()
                >= 2
        }
    }

View on GitHub (pinned to bdb87aeaa4)