{"record":{"id":"e37c65de4aca3f49","repo":"astral-sh/ruff","slug":"expected-attribute-to-be-in-the-form-of-prefix","errorCode":null,"errorMessage":"expected attribute to be in the form of [#prefix = \"...\"]","messagePattern":"expected attribute to be in the form of \\[#prefix = \"\\.\\.\\.\"\\]","errorType":"exception","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"crates/ruff_macros/src/rule_namespace.rs","lineNumber":45,"sourceCode":"\n    let mut all_prefixes = HashSet::new();\n\n    for variant in variants {\n        let mut first_chars = HashSet::new();\n        let prefixes: Result<Vec<_>, _> = variant\n            .attrs\n            .iter()\n            .filter(|attr| attr.path().is_ident(\"prefix\"))\n            .map(|attr| {\n                let Meta::NameValue(MetaNameValue {\n                    value:\n                        syn::Expr::Lit(ExprLit {\n                            lit: Lit::Str(lit), ..\n                        }),\n                    ..\n                }) = &attr.meta\n                else {\n                    return Err(Error::new(\n                        attr.span(),\n                        r#\"expected attribute to be in the form of [#prefix = \"...\"]\"#,\n                    ));\n                };\n                let str = lit.value();\n                match str.chars().next() {\n                    None => {\n                        return Err(Error::new(\n                            lit.span(),\n                            \"expected prefix string to be non-empty\",\n                        ));\n                    }\n                    Some(c) => {\n                        if !first_chars.insert(c) {\n                            return Err(Error::new(\n                                lit.span(),\n                                format!(\n                                    \"this variant already has another prefix \\","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/astral-sh/ruff/blob/26f38c119cac42e4d320ba08f09224fdec74af2c/crates/ruff_macros/src/rule_namespace.rs#L27-L63","documentation":"A syn compile error from the RuleNamespace derive: a variant's #[prefix(...)] attribute is not a name-value string literal of the form #[prefix = \"...\"]. Prefixes are extracted only from that exact attribute shape.","triggerScenarios":"Thrown at crates/ruff_macros/src/rule_namespace.rs:45 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Write the attribute as #[prefix = \"E\"]","Remove list- or symbol-shaped prefix attributes"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"26f38c119cac42e4d320ba08f09224fdec74af2c","analyzedAt":"2026-09-05T10:32:37.492Z","contentChangedAt":"2026-09-05T10:32:37.492Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}