{"record":{"id":"67a18f1a5cd52fdd","repo":"block/buzz","slug":"duplicate-name-argument","errorCode":null,"errorMessage":"duplicate `name` argument","messagePattern":"duplicate `name` argument","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"crates/buzz-datastore-tracing/src/lib.rs","lineNumber":28,"sourceCode":"\nstruct DatastoreArgs {\n    name: LitStr,\n    system: LitStr,\n    fields: Option<TokenStream2>,\n}\n\nimpl Parse for DatastoreArgs {\n    fn parse(input: ParseStream<'_>) -> Result<Self> {\n        let mut name = None;\n        let mut system = None;\n        let mut fields = None;\n\n        while !input.is_empty() {\n            let key: Ident = input.parse()?;\n            match key.to_string().as_str() {\n                \"name\" => {\n                    if name.is_some() {\n                        return Err(Error::new(key.span(), \"duplicate `name` argument\"));\n                    }\n                    input.parse::<Token![=]>()?;\n                    name = Some(input.parse()?);\n                }\n                \"system\" => {\n                    if system.is_some() {\n                        return Err(Error::new(key.span(), \"duplicate `system` argument\"));\n                    }\n                    input.parse::<Token![=]>()?;\n                    system = Some(input.parse()?);\n                }\n                \"fields\" => {\n                    if fields.is_some() {\n                        return Err(Error::new(key.span(), \"duplicate `fields` argument\"));\n                    }\n                    let content;\n                    parenthesized!(content in input);\n                    fields = Some(content.parse()?);","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/block/buzz/blob/eed74bde2f4797714335ac10c56c0b0244c1def4/crates/buzz-datastore-tracing/src/lib.rs#L10-L46","documentation":"buzz-datastore-tracing's #[datastore_span] proc macro parses its attribute arguments with a hand-written syn Parse impl. It accepts name = \"lit\", system = \"lit\", and fields(...) exactly once each; a second `name = ...` key produces this compile-time syn::Error on the duplicate key's span. It is a compile error in the crate using the macro, not a runtime failure.","triggerScenarios":"Annotating a function with #[datastore_span(name = \"fetch_user\", name = \"fetch_user_v2\", system = \"postgresql\")] — the second name key trips the duplicate check at crates/buzz-datastore-tracing/src/lib.rs:27-29 during macro expansion, failing compilation of buzz-db (the main consumer).","commonSituations":"Copy-paste of an existing annotated function followed by editing only the second name value; merge conflicts resolving to both variants of the attribute; IDE auto-completing the key again.","solutions":["Delete the duplicate `name = ...` — each argument may appear at most once per attribute.","Use `cargo check -p buzz-db` (or the crate that failed) to confirm the span error is gone.","Keep the canonical ordering name → system → fields used across the codebase to make duplicates obvious in review."],"exampleFix":"// before\n#[datastore_span(name = \"fetch_user\", system = \"postgresql\", name = \"fetch_user_v2\")]\nasync fn fetch_user(...) {}\n\n// after\n#[datastore_span(name = \"fetch_user\", system = \"postgresql\")]\nasync fn fetch_user(...) {}","handlingStrategy":"validation","validationCode":"// no runtime API — validate by compiling: `cargo check -p buzz-db`\n// the macro reports the exact span of the duplicate `name` key","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Adopt one attribute layout (name, system, fields) so duplicates stand out in diffs.","Review datastore_span attributes in PRs touching buzz-db — this family of errors is always review-catchable.","Run `cargo check` (or rely on pre-push hooks) before pushing; these never reach runtime."],"tags":["rust","proc-macro","compile-error","tracing","macro-arguments"],"backgroundTag":"duplicate-macro-argument","analyzedSha":"eed74bde2f4797714335ac10c56c0b0244c1def4","analyzedAt":"2026-08-20T04:38:24.874Z","contentChangedAt":"2026-08-20T04:38:24.874Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}