{"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":"exception","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/460ec35447493200d64290dd7f015d5a91d0fd58/crates/tauri-macros/src/command/wrapper.rs#L69-L105","documentation":"The `rename` attribute on a #[tauri::command] renames a function argument and must be given a string literal value. If the name-value expression is not an ExprLit with a Lit::Str, this syn::Error is raised at compile time.","triggerScenarios":"Writing rename with a non-string or non-literal value, e.g. rename = 42, rename = some_const, or rename without a value (path form).","commonSituations":"Attempting to rename to a computed/constant identifier; typos omitting the quotes; confusing rename with rename_all and passing multiple values.","solutions":["Pass a plain string literal: rename = \"newName\"","If the name must be computed, write the literal directly rather than referencing a const","Remove rename if the goal was something else and use rename_all for bulk case renaming"],"exampleFix":"// before\n#[tauri::command(rename_all = \"camelCase\", rename = MY_NAME)]\nfn cmd(MY_NAME: String) {}\n// after\n#[tauri::command(rename_all = \"camelCase\", rename = \"myName\")]\nfn cmd(my_name: String) {}","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass a string literal to rename = \"...\"","Don't reference constants or expressions in rename","Use rename_all for bulk case conversion and rename for individual arguments"],"tags":["proc-macro","tauri","compile-time","attributes"],"backgroundTag":"invalid-argument-format","analyzedSha":"460ec35447493200d64290dd7f015d5a91d0fd58","analyzedAt":"2026-09-18T23:55:51.277Z","contentChangedAt":"2026-09-18T23:55:51.277Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}