astral-sh/ruff · error · syn::Error
Mandatory `default` field is missing in `#[option]` attribut
Error message
Mandatory `default` field is missing in `#[option]` attribute. Specify the default using `#[option(default="..")]`.
What it means
A syn compile error from the #[option(...)] macro: the attribute does not include a `default` key. A default is mandatory because the generated documentation and schema must state the option's default value.
Source
Thrown at crates/ruff_macros/src/config.rs:274
scope = Some(get_string_literal(&meta, "scope", "option")?.value());
} else if meta.path.is_ident("example") {
let example_text = get_string_literal(&meta, "value_type", "option")?.value();
example = Some(dedent(&example_text).trim_matches('\n').to_string());
} else {
return Err(syn::Error::new(
meta.path.span(),
format!(
"Deprecated meta {:?} is not supported by ruff's option macro.",
meta.path.get_ident()
),
));
}
Ok(())
})?;
let Some(default) = default else {
return Err(syn::Error::new(
attribute.span(),
"Mandatory `default` field is missing in `#[option]` attribute. Specify the default using `#[option(default=\"..\")]`.",
));
};
let Some(value_type) = value_type else {
return Err(syn::Error::new(
attribute.span(),
"Mandatory `value_type` field is missing in `#[option]` attribute. Specify the value type using `#[option(value_type=\"..\")]`.",
));
};
let Some(example) = example else {
return Err(syn::Error::new(
attribute.span(),
"Mandatory `example` field is missing in `#[option]` attribute. Add an example using `#[option(example=\"..\")]`.",
));
};View on GitHub (pinned to 26f38c119c)
Solutions
- Add #[option(default = "...")] to the field
- Ensure the key is spelled exactly `default`
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/ruff_macros/src/config.rs:274 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/3e38f7b32bca0c27.
Report an issue: GitHub.