{"record":{"id":"3e38f7b32bca0c27","repo":"astral-sh/ruff","slug":"mandatory-default-field-is-missing-in-option","errorCode":null,"errorMessage":"Mandatory `default` field is missing in `#[option]` attribute. Specify the default using `#[option(default=\"..\")]`.","messagePattern":"Mandatory `default` field is missing in `#\\[option\\]` attribute\\. Specify the default using `#\\[option\\(default=\"\\.\\.\"\\)\\]`\\.","errorType":"exception","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"crates/ruff_macros/src/config.rs","lineNumber":274,"sourceCode":"            scope = Some(get_string_literal(&meta, \"scope\", \"option\")?.value());\n        } else if meta.path.is_ident(\"example\") {\n            let example_text = get_string_literal(&meta, \"value_type\", \"option\")?.value();\n            example = Some(dedent(&example_text).trim_matches('\\n').to_string());\n        } else {\n            return Err(syn::Error::new(\n                meta.path.span(),\n                format!(\n                    \"Deprecated meta {:?} is not supported by ruff's option macro.\",\n                    meta.path.get_ident()\n                ),\n            ));\n        }\n\n        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    };","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/astral-sh/ruff/blob/26f38c119cac42e4d320ba08f09224fdec74af2c/crates/ruff_macros/src/config.rs#L256-L292","documentation":"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.","triggerScenarios":"Thrown at crates/ruff_macros/src/config.rs:274 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add #[option(default = \"...\")] to the field","Ensure the key is spelled exactly `default`"],"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"}