{"record":{"id":"f971c426a1fd5953","repo":"tauri-apps/tauri","slug":"expected-string-literal-for-rename","errorCode":null,"errorMessage":"expected string literal for rename","messagePattern":"expected string literal for rename","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"crates/tauri-macros/src/command/wrapper.rs","lineNumber":87,"sourceCode":"                \"snake_case\" => ArgumentCase::Snake,\n                \"camelCase\" => ArgumentCase::Camel,\n                _ => {\n                  return Err(syn::Error::new(\n                    s.span(),\n                    \"expected \\\"camelCase\\\" or \\\"snake_case\\\"\",\n                  ))\n                }\n              };\n            }\n          } else if v.path.is_ident(\"rename\") {\n            if let Expr::Lit(ExprLit {\n              lit: Lit::Str(s), ..\n            }) = v.value\n            {\n              let lit = s.value();\n              wrapper_attributes.rename = RenamePolicy::Rename(quote!(#lit));\n            } else {\n              return Err(syn::Error::new(\n                v.span(),\n                \"expected string literal for rename\",\n              ));\n            }\n          } else if v.path.is_ident(\"root\") {\n            if let Expr::Lit(ExprLit {\n              lit: Lit::Str(s),\n              attrs: _,\n            }) = v.value\n            {\n              let lit = s.value();\n\n              wrapper_attributes.root = if lit == \"crate\" {\n                quote!($crate)\n              } else {\n                let ident = Ident::new(&lit, Span::call_site());\n                quote!(#ident)\n              };","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/tauri-apps/tauri/blob/52e4b6e71d8632a7e648f866c442e287ecddee34/crates/tauri-macros/src/command/wrapper.rs#L69-L105","documentation":"The rename key of #[tauri::command] overrides the exposed name of a single command and must be a plain string literal, because the macro splices the literal into generated code. The parser explicitly checks for Expr::Lit with Lit::Str; any other expression (number, const, macro call) is rejected with the span on the whole name=value pair.","triggerScenarios":"#[tauri::command(rename = 5)], #[tauri::command(rename = MY_CONST)], or #[tauri::command(rename = concat!(\"api\", \"_thing\"))].","commonSituations":"Trying to build the command name from consts or macros to avoid repetition; unquoting mistakes when copying from template strings; JSON-style thinking where rename values arrive from elsewhere.","solutions":["Pass a plain string literal: #[tauri::command(rename = \"myCustomName\")]","If you need a computed name, wrap the command in a generated module via a small local macro that interpolates the literal","Double-check you used rename (single command name) and not rename_all (argument casing)"],"exampleFix":"// before\nconst API_NAME: &str = \"fetchItems\";\n#[tauri::command(rename = API_NAME)]\nfn fetch_items() {}\n// after\n#[tauri::command(rename = \"fetchItems\")]\nfn fetch_items() {}","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass a plain string literal to rename","Do not use consts or macro calls in rename — the macro splices the literal at compile time","Keep rename (command name) and rename_all (argument casing) straight"],"tags":["macros","command","rename","compile-time","string-literal"],"backgroundTag":"macro-attribute-syntax-error","analyzedSha":"52e4b6e71d8632a7e648f866c442e287ecddee34","analyzedAt":"2026-08-20T13:59:20.734Z","contentChangedAt":"2026-08-20T13:59:20.734Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}