diesel-rs/diesel · error

got invalid case identifier

Error message

got invalid case identifier: `{s}`
only: `lowercase`, `UPPERCASE`, `PascalCase`, `camelCase`, `snake_case`, `SCREAMING_SNAKE_CASE`, `kebab-case` and `SCREAMING-KEBAB-CASE` are supported

What it means

Compile-time error from parsing the rename_all-style string of #[diesel(...)] attribute options. RenameVariants::parse reads a string literal and maps it to one of eight supported case conventions (lowercase, UPPERCASE, PascalCase, camelCase, snake_case, SCREAMING_SNAKE_CASE, kebab-case, SCREAMING-KEBAB-CASE); any other string is rejected. This is a validation guard on the literal value, typically a typo or unsupported case name. Fix: use one of the listed case identifiers.

Solutions

  1. Use one of the supported case names such as `snake_case`, `PascalCase`, or `SCREAMING_SNAKE_CASE`
  2. Check the spelling and hyphenation of the case name
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at diesel_attribute_parser/src/lib.rs:500 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at diesel_attribute_parser/src/lib.rs:500

    KebabCase,
    ScreamingKebabCase,
}

impl syn::parse::Parse for RenameVariants {
    fn parse(input: syn::parse::ParseStream) -> Result<Self> {
        let lit = input.parse::<syn::LitStr>()?;
        let v = lit.value();
        let v = match v.as_str() {
            "lowercase" => Self::LowerCase,
            "UPPERCASE" => Self::UpperCase,
            "PascalCase" => Self::PascalCase,
            "camelCase" => Self::CamelCase,
            "snake_case" => Self::SnakeCase,
            "SCREAMING_SNAKE_CASE" => Self::ScreamingSnakeCase,
            "kebab-case" => Self::KebabCase,
            "SCREAMING-KEBAB-CASE" => Self::ScreamingKebabCase,
            s => {
                return Err(syn::Error::new(
                    lit.span(),
                    format!(
                        "got invalid case identifier: `{s}`\n\
                         only: `lowercase`, `UPPERCASE`, `PascalCase`, `camelCase`, \
                         `snake_case`, `SCREAMING_SNAKE_CASE`, `kebab-case` \
                         and `SCREAMING-KEBAB-CASE` are supported"
                    ),
                ));
            }
        };
        Ok(v)
    }
}

impl RenameVariants {
    pub fn apply_case_to_enum_variant(&self, input: String) -> String {
        match self {
            // Rust enum variants are already pascal case

View on GitHub (pinned to 6fa6ed01b2)