{"record":{"id":"de7e35351fa172e1","repo":"vectordotdev/vector","slug":"must-exist","errorCode":null,"errorMessage":"must exist","messagePattern":"must exist","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/vector-config-macros/src/configurable.rs","lineNumber":1012,"sourceCode":"                required,\n                None\n            );\n\n            // If we have any flattened subschemas, deal with them now.\n            if !flattened_subschemas.is_empty() {\n                ::vector_config::schema::convert_to_flattened_schema(&mut schema, flattened_subschemas);\n            }\n\n            schema\n        }\n    }\n}\n\nfn generate_enum_newtype_struct_variant_schema(\n    variant: &Variant<'_>,\n    is_potentially_ambiguous: bool,\n) -> proc_macro2::TokenStream {\n    let field = variant.fields().first().expect(\"must exist\");\n    if field.required_one_of().is_some() {\n        return syn::Error::new(\n            field.span(),\n            \"`required_one_of` is not supported on enum variant fields\",\n        )\n        .to_compile_error();\n    }\n    let field_schema = generate_struct_field(field, &[]);\n    let maybe_fill_discriminant_map = is_potentially_ambiguous.then(|| {\n        let variant_name = variant.ident().to_string();\n        quote! {\n            discriminant_map.insert(\n                #variant_name,\n                ::vector_config::schema::EnumDiscriminant::schema(subschema.clone()),\n            );\n        }\n    });\n","sourceCodeStart":994,"sourceCodeEnd":1030,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/lib/vector-config-macros/src/configurable.rs#L994-L1030","documentation":"This panic occurs in vector-config-macros when generating a schema for an enum newtype (tuple) variant that has no fields at all. `variant.fields().first().expect(\"must exist\")` assumes the variant classified as a newtype variant has exactly one positional field; a zero-field variant breaks that assumption. It is a derive-time panic surfaced as a compiler error in the user's crate, not a runtime failure.","triggerScenarios":"Deriving `Configurable` on an enum containing a unit-style variant (zero fields) that the macro's classification logic mistakenly routes into `generate_enum_newtype_struct_variant_schema`, causing `.first()` to return None.","commonSituations":"Macro-internal misclassification after refactoring variant-shape detection; hand-edited or proc-macro-generated enums where the newtype path is invoked for a unit variant like `Foo` instead of `Foo(Inner)`.","solutions":["Verify the failing enum variant is actually a newtype variant with exactly one unnamed field: `Variant(InnerType)`","Fix the variant classification in generate_enum_variant_schema so unit variants (0 fields) are not routed to the newtype-variant schema generator","In the macro, match on fields.len() == 1 explicitly and emit a compile_error! with the variant span instead of expect()"],"exampleFix":"// before\nlet field = variant.fields().first().expect(\"must exist\");\n// after\nlet field = variant.fields().first().ok_or_else(|| {\n    syn::Error::new(variant.span(), \"newtype enum variant must have exactly one field\")\n        .to_compile_error()\n})?;","handlingStrategy":"validation","validationCode":"// In the macro, before .first().expect():\nassert_eq!(variant.fields().len(), 1, \"newtype variant must have exactly one field\");","typeGuard":"fn is_newtype_variant(v: &syn::Variant) -> bool {\n    matches!(&v.fields, syn::Fields::Unnamed(f) if f.unnamed.len() == 1)\n}","tryCatchPattern":null,"preventionTips":["Verify the failing variant is written as `Name(T)` with one positional field","Route unit variants through their own schema generator","Prefer ok_or_else with syn::Error over expect in derive code"],"tags":["rust","proc-macro","derive-macro","panic"],"backgroundTag":"internal-invariant-violation","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"}