diesel-rs/diesel · error

expected attribute `name` help: the correct format looks…

Error message

expected attribute `name`
help: the correct format looks like #[diesel({SQLITE_TYPE_NOTE})]

What it means

This error comes from diesel's `#[diesel(sqlite_type(...))]` attribute parser. The attribute requires a `name` key specifying the SQLite type name, and the parser raises this error when the attribute content is empty or contains keys but no `name`. It includes a help line showing the expected format.

Solutions

  1. Add the required `name` key: `#[diesel(sqlite_type(name = "..."))]`
  2. Check spelling of the key (must be exactly `name`)
  3. Consult the SQLITE_TYPE_NOTE help text in the diesel docs for the correct format

Example fix

// before
#[diesel(sqlite_type())]
struct MyType;
// after
#[diesel(sqlite_type(name = "integer"))]
struct MyType;
Defensive patterns

Strategy: validation

Validate before calling

// Check attribute content before expanding
let attr_src = quote::quote! { #attr }.to_string();
assert!(attr_src.contains("name"), "#[diesel(sqlite_type(...))] requires `name = ...`");

Prevention

When it happens

Trigger: Writing `#[diesel()]` or `#[diesel(sqlite_type)]`/`#[diesel(sqlite_type())]` without a `name = ...` entry inside parentheses when the sqlite_type parser runs on the attribute.

Common situations: Hand-writing a `SqliteType` registration or copying an example attribute and forgetting the `name = "..."` key; typos like `nam =` also drop into this path if unknown keys are skipped.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of diesel-rs/diesel@6fa6ed01b2 (2026-09-07). Data as JSON: /api/errors/e145754af435e78f. Report an issue: GitHub.

Appendix: source

Thrown at diesel_attribute_parser/src/parsers/sqlite_type.rs:43

pub struct SqliteType {
    pub name: LitStr,
}

impl Parse for SqliteType {
    fn parse(input: ParseStream) -> Result<Self> {
        let mut name = None;

        for attr in Punctuated::<Attr, Comma>::parse_terminated(input)? {
            match attr {
                Attr::Name(value) => name = Some(value),
            }
        }

        if let Some(name) = name {
            Ok(SqliteType { name })
        } else {
            Err(syn::Error::new(
                input.span(),
                format!(
                    "expected attribute `name`\n\
                     help: the correct format looks like #[diesel({SQLITE_TYPE_NOTE})]"
                ),
            ))
        }
    }
}

View on GitHub (pinned to 6fa6ed01b2)