diesel-rs/diesel · error
unexpected end of input, expected parentheses
Error message
unexpected end of input, expected parentheses
What it means
The deprecated `primary_key` attribute requires a parenthesized list of column identifiers; the attribute was given with empty or no parentheses, so the parser errors with `unexpected end of input, expected parentheses`.
Solutions
- Add the key columns: `#[diesel(primary_key(id))]` or `#[diesel(primary_key(a, b))]` for composite keys
- Remove the attribute to fall back to the default `id` primary key
Example fix
// before #[diesel(primary_key)] // after #[diesel(primary_key(id))]
Defensive patterns
Strategy: validation
Validate before calling
// compile-time: #[diesel(primary_key(id))] or #[diesel(primary_key(a, b))]
Prevention
- List the key columns explicitly whenever overriding the primary key
- Rely on the default `id` key when no override is needed
When it happens
Trigger: Writing `#[diesel(primary_key)]` without `(col1, col2)` on a table/struct in `QueryableByName`/`Identifiable` derives.
Common situations: Declaring a custom primary key but forgetting the column list, or deleting the list during refactoring.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- unexpected end of input, expected parentheses help: the…
- expected `foreign_key`
- unexpected end of input, expected parentheses
- expected `treat_none_as_null`
- unexpected end of input, expected parentheses help: the…
AI-assisted analysis of diesel-rs/diesel@6fa6ed01b2 (2026-09-07).
Data as JSON: /api/errors/6133f4b04ad44968.
Report an issue: GitHub.
Appendix: source
Thrown at diesel_attribute_parser/src/deprecated/primary_key.rs:8
use syn::parse::{Parse, ParseStream, Result};
use syn::punctuated::Punctuated;
use syn::token::Comma;
use syn::{Ident, parenthesized};
pub fn parse_primary_key(name: Ident, input: ParseStream) -> Result<Punctuated<Ident, Comma>> {
if input.is_empty() {
return Err(syn::Error::new(
name.span(),
"unexpected end of input, expected parentheses",
));
}
let content;
parenthesized!(content in input);
content.parse_terminated(Ident::parse, syn::Token![,])
}
View on GitHub (pinned to 6fa6ed01b2)