astral-sh/ruff · error · syn::Error
Mandatory `value_type` field is missing in `#[option]` attri
Error message
Mandatory `value_type` field is missing in `#[option]` attribute. Specify the value type using `#[option(value_type="..")]`.
What it means
Compile-time error emitted by the #[option] derive/attribute macro in ruff_macros while parsing a struct field's attributes. Every field marked #[option] must declare its value type so configuration documentation and schema generation can describe it; when parse_field_attributes (invoked via handle_option) finishes scanning the attribute's meta items without having collected a value_type entry, it reports this error pointing at the attribute span. The macro user fixes it by adding value_type=".." to the #[option(...)] attribute. Not a runtime error and not catchable — it aborts proc-macro expansion.
Source
Thrown at crates/ruff_macros/src/config.rs:281
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=\"..\")]`.",
));
};
Ok(FieldAttributes {
default,
value_type,
example,
scope,
})View on GitHub (pinned to 26f38c119c)
Solutions
- Add #[option(value_type = "...")] describing the option's type
- Check for typos in the key name
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/ruff_macros/src/config.rs:281 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/be36028d5d6bd360.
Report an issue: GitHub.