{"record":{"id":"0136db0e913c753a","repo":"diesel-rs/diesel","slug":"expected-foreign-key","errorCode":null,"errorMessage":"expected `foreign_key`","messagePattern":"expected `foreign_key`","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"diesel_attribute_parser/src/deprecated/belongs_to.rs","lineNumber":44,"sourceCode":"        if name == \"parent\" {\n            let lit_str = parse_eq_and_lit_str(name, &content, BELONGS_TO_NOTE)?;\n            lit_str.parse()?\n        } else {\n            LitStr::new(&name.to_string(), name.span()).parse()?\n        }\n    } else {\n        content.parse()?\n    };\n\n    let mut foreign_key = None;\n\n    if content.peek(Comma) {\n        content.parse::<Comma>()?;\n\n        let name: Ident = content.parse()?;\n\n        if name != \"foreign_key\" {\n            return Err(syn::Error::new(name.span(), \"expected `foreign_key`\"));\n        }\n\n        let lit_str = parse_eq_and_lit_str(name, &content, BELONGS_TO_NOTE)?;\n        foreign_key = Some(lit_str.parse()?);\n    }\n\n    Ok(BelongsTo {\n        parent,\n        foreign_key,\n    })\n}\n","sourceCodeStart":26,"sourceCodeEnd":56,"githubUrl":"https://github.com/diesel-rs/diesel/blob/6fa6ed01b24b24248ab2a611698d0a7c6a2e9120/diesel_attribute_parser/src/deprecated/belongs_to.rs#L26-L56","documentation":"Compile-time error from the deprecated #[belongs_to(...)] attribute parser. After the parent model name, the only additional option accepted in the old syntax is `foreign_key = \"...\"`; any other trailing identifier (e.g. a misspelled `foreignkeys`) is rejected with this sentinel. Fires when parsing arguments of #[belongs_to(Parent, ...)] during the deprecated attribute path. Fix: use `foreign_key` or drop the extra argument.","triggerScenarios":"Writing `#[diesel(belongs_to(User, some_other_key = \"x\"))]` or any option other than `foreign_key = \"...\"` inside the parentheses.","commonSituations":"Guessing option names, using options from newer diesel versions that the old deprecated parser does not know, or typos like `foreignkeys`/`foreign-key`.","solutions":["Use `foreign_key = \"...\"` in the attribute","Remove the unrecognized argument and keep only supported keys","Prefer the modern non-deprecated attribute form"],"exampleFix":"// before\n#[diesel(belongs_to(User, fk = \"author_id\"))]\n// after\n#[diesel(belongs_to(User, foreign_key = \"author_id\"))]","handlingStrategy":"validation","validationCode":"// only allowed option inside belongs_to(...): foreign_key = \"...\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use only documented option names in attribute parentheses","Prefer current diesel association syntax over deprecated forms"],"tags":["rust","proc-macro","diesel-derive","attribute-syntax"],"backgroundTag":"invalid-argument-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"}