{"record":{"id":"0c43ea6958573155","repo":"BoundaryML/baml","slug":"variant-has-more-than-one-axis","errorCode":null,"errorMessage":"variant `{}` has more than one `#[axis(..)]`","messagePattern":"variant `(.+?)` has more than one `#\\[axis\\(\\.\\.\\)\\]`","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_type_macros/src/parse.rs","lineNumber":398,"sourceCode":"            generics: master.generics,\n            members: resolved_members,\n            satellites: resolved_satellites,\n            variants,\n        })\n    }\n}\n\nfn resolve_variant(\n    variant: syn::Variant,\n    axis_index: &impl Fn(&Ident) -> syn::Result<usize>,\n) -> syn::Result<MVariant> {\n    let span = variant.ident.span();\n    let mut axis_ident: Option<Ident> = None;\n    let mut attrs = Vec::new();\n    for attr in variant.attrs {\n        if attr.path().is_ident(\"axis\") {\n            if axis_ident.is_some() {\n                return Err(syn::Error::new(\n                    span,\n                    format!(\n                        \"variant `{}` has more than one `#[axis(..)]`\",\n                        variant.ident\n                    ),\n                ));\n            }\n            axis_ident = Some(attr.parse_args_with(Ident::parse_any)?);\n        } else {\n            attrs.push(attr);\n        }\n    }\n    let axis_ident = axis_ident.ok_or_else(|| {\n        syn::Error::new(\n            span,\n            format!(\n                \"variant `{}` must declare exactly one `#[axis(..)]`\",\n                variant.ident","sourceCodeStart":380,"sourceCodeEnd":416,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_type_macros/src/parse.rs#L380-L416","documentation":"In `resolve_variant`, an enum variant may carry at most one `#[axis(..)]` attribute. A second one makes the axis identifier ambiguous, so the macro aborts at parse time. The non-axis attributes are collected separately and the first axis wins otherwise, but duplicates are hard errors.","triggerScenarios":"Writing two `#[axis(..)]` attributes on the same variant of a derive-defined enum; `variant.attrs` contains more than one attribute whose path is `axis` while `axis_ident` is already `Some`.","commonSituations":"Copy-pasting variant definitions and forgetting to delete the original `#[axis(..)]`; merging branches that both added an axis attribute.","solutions":["Delete the duplicate `#[axis(..)]` attribute, keeping only one per variant.","Merge the axis payloads into a single `#[axis(..)]` if both carried information.","Rename the variant if the two axes were intended for distinct variants."],"exampleFix":"// before\n#[axis(Type)]\n#[axis(Shape)]\nVariant,\n// after\n#[axis(Type)]\nVariant,","handlingStrategy":"validation","validationCode":"// rustfmt/clippy side check or code review\n// each variant's attrs must contain at most one #[axis(..)]","typeGuard":null,"tryCatchPattern":null,"preventionTips":["One `#[axis(..)]` per variant — grep variants for duplicates after copy-paste","Resolve merge conflicts around variant attributes carefully","Keep variant declarations in a consistent formatting to spot duplicates"],"tags":["proc-macro","compile-time","attributes","rust"],"backgroundTag":"mutually-exclusive-options","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}