{"record":{"id":"e7be5a8ee701543c","repo":"diesel-rs/diesel","slug":"unknown-attribute-expected-prefix","errorCode":null,"errorMessage":"unknown attribute, expected{prefix} `{}`","messagePattern":"unknown attribute, expected(.+?) `(.+?)`","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"diesel_attribute_parser/src/util.rs","lineNumber":8,"sourceCode":"use syn::parse::{Parse, ParseStream, Peek, Result};\nuse syn::token::Eq;\nuse syn::{Ident, Type, parenthesized};\n\npub fn unknown_attribute(name: &Ident, valid: &[&str]) -> syn::Error {\n    let prefix = if valid.len() == 1 { \"\" } else { \" one of\" };\n\n    syn::Error::new(\n        name.span(),\n        format!(\n            \"unknown attribute, expected{prefix} `{}`\",\n            valid.join(\"`, `\")\n        ),\n    )\n}\n\npub fn parse_eq<T: Parse>(input: ParseStream, help: &str) -> Result<T> {\n    if input.is_empty() {\n        return Err(syn::Error::new(\n            input.span(),\n            format!(\n                \"unexpected end of input, expected `=`\\n\\\n                 help: the correct format looks like `#[diesel({help})]`\",\n            ),\n        ));\n    }","sourceCodeStart":1,"sourceCodeEnd":26,"githubUrl":"https://github.com/diesel-rs/diesel/blob/6fa6ed01b24b24248ab2a611698d0a7c6a2e9120/diesel_attribute_parser/src/util.rs#L1-L26","documentation":"Generic error emitted by diesel's attribute parser utilities when an unrecognized attribute key is encountered. It lists the set of valid keys expected at that position, formatted as a backtick-joined list. If exactly one key is valid, the message omits the 'one of' prefix.","triggerScenarios":"Passing any key to a `#[diesel(...)]` attribute that is not in the valid list for that derive/position, e.g. `#[diesel(treat_nane_as_null = true)]` (typo) or a key valid on one derive but not another.","commonSituations":"Typos in attribute names; copying attributes between derives where the key isn't supported; using attributes from an older/newer diesel version that renamed keys.","solutions":["Use one of the valid keys listed in the error message","Fix typos in the attribute name","Check the diesel version's documentation for supported keys on that derive"],"exampleFix":"// before\n#[diesel(table_name = users, primary_key(id, extra_key))]\n// after\n#[diesel(table_name = users, primary_key(id))]","handlingStrategy":"validation","validationCode":"const VALID_KEYS: &[&str] = &[\"sqlite_type\", \"table_name\", \"primary_key\"];\nassert!(VALID_KEYS.contains(&key), \"unknown diesel attribute key: {}\", key);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify attribute keys against the current diesel version's docs","Watch for typos in long key names like `treat_none_as_null`","Don't copy attribute keys between different derives"],"tags":["rust","proc-macro","diesel","attribute-parsing"],"backgroundTag":"invalid-enum-value","analyzedSha":"6fa6ed01b24b24248ab2a611698d0a7c6a2e9120","analyzedAt":"2026-09-07T01:50:13.074Z","contentChangedAt":"2026-09-07T01:50:13.074Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}