{"record":{"id":"5e5a3ce1da3c2171","repo":"quickwit-oss/quickwit","slug":"serde-multikey-was-applied-multiple-time-to-the","errorCode":null,"errorMessage":"`serde_multikey` was applied multiple time to the same field","messagePattern":"`serde_multikey` was applied multiple time to the same field","errorType":"exception","errorClass":"proc-macro compile error","httpStatus":null,"severity":"error","filePath":"quickwit/quickwit-macros/src/lib.rs","lineNumber":463,"sourceCode":"        if res.proxy_fields.is_empty() {\n            todo!(\"throw error\")\n        }\n\n        Ok(res)\n    }\n}\n\nfn parse_attributes(\n    attributes: Vec<Attribute>,\n    field_name: &Ident,\n) -> Result<(Option<MultiKeyOptions>, Vec<Attribute>), Error> {\n    let (mut multikey_attributes, normal_attributes): (Vec<_>, _) = attributes\n        .into_iter()\n        .partition(|attr| attr.path().is_ident(\"serde_multikey\"));\n\n    if multikey_attributes.len() > 1 {\n        let last = multikey_attributes.last().unwrap();\n        return Err(Error::new(\n            last.pound_token.spans[0],\n            \"`serde_multikey` was applied multiple time to the same field\",\n        ));\n    }\n    let options = if let Some(multikey_attribute) = multikey_attributes.pop() {\n        let Meta::List(meta_list) = multikey_attribute.meta else {\n            return Err(Error::new(\n                multikey_attribute.pound_token.spans[0],\n                \"`serde_multikey` require list-style arguments\",\n            ));\n        };\n        let mut options: MultiKeyOptions = syn::parse2(meta_list.tokens)?;\n        options.main_field_name = field_name.clone();\n        Some(options)\n    } else {\n        None\n    };\n","sourceCodeStart":445,"sourceCodeEnd":481,"githubUrl":"https://github.com/quickwit-oss/quickwit/blob/a39730c5cdcd1a4fe798403737ae293999ea21f8/quickwit/quickwit-macros/src/lib.rs#L445-L481","documentation":"This compile-time proc-macro error comes from quickwit's custom `#[serde_multikey(...)]` attribute. The `parse_attributes` helper partitions a field's attributes and requires at most one `serde_multikey`; applying it more than once to the same field is ambiguous (which set of options should win?), so the macro emits a syn::Error pointing at the last duplicate occurrence.","triggerScenarios":"Compiling a struct derived via the proxy-struct macro (generate_proxy_struct) where a single field is annotated with two or more `#[serde_multikey(...)]` attributes.","commonSituations":"Merging code from two branches that each added `serde_multikey` to the same field; copy-pasting an attribute line and forgetting to remove the original; mechanically adding the attribute without noticing it was already present.","solutions":["Remove the duplicate `#[serde_multikey(...)]` attribute from the field, keeping only one.","Merge the two attribute argument lists into a single `#[serde_multikey(...)]` if both sets of options are needed.","If the duplicate came from a macro or code generator you control, deduplicate the attribute before emitting the struct."],"exampleFix":"// before\n#[serde_multikey(main_key = \"a\", sub_key = \"b\")]\n#[serde_multikey(main_key = \"a\", sub_key = \"c\")]\nmy_field: MyType,\n// after\n#[serde_multikey(main_key = \"a\", sub_key = \"c\")]\nmy_field: MyType,","handlingStrategy":"validation","validationCode":"// compile-time: ensure each field carries at most one serde_multikey attribute\nlet dupes = fields.iter().filter(|f| f.attrs.iter().filter(|a| a.path().is_ident(\"serde_multikey\")).count() > 1).count();\nassert_eq!(dupes, 0, \"duplicate serde_multikey attribute\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Search fields for `serde_multikey` before adding it again (grep the struct definition).","When merging branches, resolve attribute conflicts on derived structs explicitly.","Keep multi-key field annotations documented so contributors know one is already present."],"tags":["proc-macro","rust","compile-time","duplicate-attribute"],"backgroundTag":"invalid-argument-value","analyzedSha":"a39730c5cdcd1a4fe798403737ae293999ea21f8","analyzedAt":"2026-09-08T13:19:37.784Z","contentChangedAt":"2026-09-08T13:19:37.784Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}