tauri-apps/tauri · error · syn::Error

expected "camelCase" or "snake_case"

Error message

expected "camelCase" or "snake_case"

What it means

The rename_all attribute of #[tauri::command] only accepts the exact string literals "snake_case" or "camelCase". Any other value raises this syn::Error at compile time, pointing at the offending string literal.

Solutions

  1. Change the value to exactly "snake_case" or "camelCase"
  2. If kebab-case etc. is needed, rename parameters manually with the `rename` attribute instead
  3. Quote the value: rename_all = "camelCase" (not rename_all = camelCase)

Example fix

// before
#[tauri::command(rename_all = "kebab-case")]
// after
#[tauri::command(rename_all = "camelCase")]
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: #[tauri::command(rename_all = "kebab-case")], rename_all = "SCREAMING_SNAKE_CASE", a typo like "camelcase", or passing a non-literal expression such as rename_all = MY_CASE.

Common situations: Assuming serde's full rename_all vocabulary (kebab-case, PascalCase, UPPER CASE) is supported; typos in casing; forgetting quotes around the value.

Understand the failure class

Background: "invalid argument", "unknown mode", "not supported": invalid enum-like argument errors explained — this error's family across 19 libraries.

Related errors


AI-assisted analysis of tauri-apps/tauri@460ec35447 (2026-09-18). Data as JSON: /api/errors/d7f01dc2e8199470. Report an issue: GitHub.

Appendix: source

Thrown at crates/tauri-macros/src/command/wrapper.rs:72

    let attrs = Punctuated::<WrapperAttributeKind, Token![,]>::parse_terminated(input)?;
    for attr in attrs {
      match attr {
        WrapperAttributeKind::Meta(Meta::List(_)) => {
          return Err(syn::Error::new(input.span(), "unexpected list input"));
        }
        WrapperAttributeKind::Meta(Meta::NameValue(v)) => {
          if v.path.is_ident("rename_all") {
            if let Expr::Lit(ExprLit {
              lit: Lit::Str(s),
              attrs: _,
            }) = v.value
            {
              wrapper_attributes.argument_case = match s.value().as_str() {
                "snake_case" => ArgumentCase::Snake,
                "camelCase" => ArgumentCase::Camel,
                _ => {
                  return Err(syn::Error::new(
                    s.span(),
                    "expected \"camelCase\" or \"snake_case\"",
                  ));
                }
              };
            }
          } else if v.path.is_ident("rename") {
            if let Expr::Lit(ExprLit {
              lit: Lit::Str(s), ..
            }) = v.value
            {
              let lit = s.value();
              wrapper_attributes.rename = RenamePolicy::Rename(quote!(#lit));
            } else {
              return Err(syn::Error::new(
                v.span(),
                "expected string literal for rename",
              ));

View on GitHub (pinned to 460ec35447)