astral-sh/ruff · error · syn::Error
expected {attribute_name} attribute to be a string: `{meta_n
Error message
expected {attribute_name} attribute to be a string: `{meta_name} = "..."` What it means
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 = "..."`.
Source
Thrown at crates/ruff_macros/src/config.rs:351
while let syn::Expr::Group(e) = value {
value = &e.expr;
}
if let syn::Expr::Lit(ExprLit {
lit: Lit::Str(lit), ..
}) = value
{
let suffix = lit.suffix();
if !suffix.is_empty() {
return Err(syn::Error::new(
lit.span(),
format!("unexpected suffix `{suffix}` on string literal"),
));
}
Ok(lit.clone())
} else {
Err(syn::Error::new(
expr.span(),
format!("expected {attribute_name} attribute to be a string: `{meta_name} = \"...\"`"),
))
}
}
#[derive(Default, Debug)]
struct DeprecatedAttribute {
since: Option<String>,
note: Option<String>,
}
View on GitHub (pinned to 26f38c119c)
Solutions
- Wrap the value in double quotes so it is a string literal
- Use a plain string, not an expression, for the attribute value
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/ruff_macros/src/config.rs:351 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of astral-sh/ruff@26f38c119c (2026-09-05).
Data as JSON: /api/errors/bf47e8d155eccda6.
Report an issue: GitHub.