{"record":{"id":"bf47e8d155eccda6","repo":"astral-sh/ruff","slug":"expected-attribute-name-attribute-to-be-a-string","errorCode":null,"errorMessage":"expected {attribute_name} attribute to be a string: `{meta_name} = \"...\"`","messagePattern":"expected (.+?) attribute to be a string: `(.+?) = \"\\.\\.\\.\"`","errorType":"exception","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"crates/ruff_macros/src/config.rs","lineNumber":351,"sourceCode":"    while let syn::Expr::Group(e) = value {\n        value = &e.expr;\n    }\n\n    if let syn::Expr::Lit(ExprLit {\n        lit: Lit::Str(lit), ..\n    }) = value\n    {\n        let suffix = lit.suffix();\n        if !suffix.is_empty() {\n            return Err(syn::Error::new(\n                lit.span(),\n                format!(\"unexpected suffix `{suffix}` on string literal\"),\n            ));\n        }\n\n        Ok(lit.clone())\n    } else {\n        Err(syn::Error::new(\n            expr.span(),\n            format!(\"expected {attribute_name} attribute to be a string: `{meta_name} = \\\"...\\\"`\"),\n        ))\n    }\n}\n\n#[derive(Default, Debug)]\nstruct DeprecatedAttribute {\n    since: Option<String>,\n    note: Option<String>,\n}\n","sourceCodeStart":333,"sourceCodeEnd":363,"githubUrl":"https://github.com/astral-sh/ruff/blob/26f38c119cac42e4d320ba08f09224fdec74af2c/crates/ruff_macros/src/config.rs#L333-L363","documentation":"A syn compile error from get_string_literal: the value of a default/value_type/scope/example key parsed to an expression that is not a string literal (e.g. a number, bool, or function call). The macro grammar requires `key = \"...\"`.","triggerScenarios":"Thrown at crates/ruff_macros/src/config.rs:351 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Wrap the value in double quotes so it is a string literal","Use a plain string, not an expression, for the attribute value"],"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"}