{"record":{"id":"377f37da6c25439a","repo":"astral-sh/ruff","slug":"mandatory-example-field-is-missing-in-option","errorCode":null,"errorMessage":"Mandatory `example` field is missing in `#[option]` attribute. Add an example using `#[option(example=\"..\")]`.","messagePattern":"Mandatory `example` field is missing in `#\\[option\\]` attribute\\. Add an example using `#\\[option\\(example=\"\\.\\.\"\\)\\]`\\.","errorType":"exception","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"crates/ruff_macros/src/config.rs","lineNumber":288,"sourceCode":"        Ok(())\n    })?;\n\n    let Some(default) = default else {\n        return Err(syn::Error::new(\n            attribute.span(),\n            \"Mandatory `default` field is missing in `#[option]` attribute. Specify the default using `#[option(default=\\\"..\\\")]`.\",\n        ));\n    };\n\n    let Some(value_type) = value_type else {\n        return Err(syn::Error::new(\n            attribute.span(),\n            \"Mandatory `value_type` field is missing in `#[option]` attribute. Specify the value type using `#[option(value_type=\\\"..\\\")]`.\",\n        ));\n    };\n\n    let Some(example) = example else {\n        return Err(syn::Error::new(\n            attribute.span(),\n            \"Mandatory `example` field is missing in `#[option]` attribute. Add an example using `#[option(example=\\\"..\\\")]`.\",\n        ));\n    };\n\n    Ok(FieldAttributes {\n        default,\n        value_type,\n        example,\n        scope,\n    })\n}\n\nfn parse_deprecated_attribute(attribute: &Attribute) -> syn::Result<DeprecatedAttribute> {\n    let mut deprecated = DeprecatedAttribute::default();\n    attribute.parse_nested_meta(|meta| {\n        if meta.path.is_ident(\"note\") {\n            deprecated.note = Some(get_string_literal(&meta, \"note\", \"deprecated\")?.value());","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/astral-sh/ruff/blob/26f38c119cac42e4d320ba08f09224fdec74af2c/crates/ruff_macros/src/config.rs#L270-L306","documentation":"Compile-time error from the #[option] macro's field-attribute parser. Each #[option] field must supply an example value, which ruff embeds in generated configuration documentation; if parse_field_attributes (reached through handle_option) collects default and value_type but never an example, it raises this error at the attribute's span. It is a developer-facing authoring error in ruff's own rule/option definitions, resolved by adding example=\"..\" to the #[option(...)] attribute; it aborts macro expansion rather than being recoverable at runtime.","triggerScenarios":"Thrown at crates/ruff_macros/src/config.rs:288 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add #[option(example = \"...\")] with a valid config snippet","Run cargo dev generate-all after adding the example"],"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"}