{"record":{"id":"7ad51727437af8b1","repo":"tauri-apps/tauri","slug":"unexpected-expression-for-capability","errorCode":null,"errorMessage":"unexpected expression for capability","messagePattern":"unexpected expression for capability","errorType":"exception","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"crates/tauri-macros/src/context.rs","lineNumber":80,"sourceCode":"        }\n        Meta::NameValue(v) => {\n          let ident = v.path.require_ident()?;\n          match ident.to_string().as_str() {\n            \"capabilities\" => {\n              if let Expr::Array(array) = v.value {\n                capabilities.replace(\n                  array\n                    .elems\n                    .into_iter()\n                    .map(|e| {\n                      if let Expr::Lit(ExprLit {\n                        attrs: _,\n                        lit: Lit::Str(s),\n                      }) = e\n                      {\n                        Ok(s.value().into())\n                      } else {\n                        Err(syn::Error::new(\n                          input.span(),\n                          \"unexpected expression for capability\",\n                        ))\n                      }\n                    })\n                    .collect::<Result<Vec<_>, syn::Error>>()?,\n                );\n              } else {\n                return Err(syn::Error::new(\n                  input.span(),\n                  \"unexpected value for capabilities\",\n                ));\n              }\n            }\n            \"assets\" => {\n              assets.replace(v.value);\n            }\n            \"test\" => {","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/tauri-apps/tauri/blob/460ec35447493200d64290dd7f015d5a91d0fd58/crates/tauri-macros/src/context.rs#L62-L98","documentation":"This is a compile-time error from the `tauri::generate_context!` macro. When the `capabilities` attribute is given an array, every element must be a string literal (a path to a capability file). The macro rejects any element that is another kind of expression (number, identifier, function call, etc.) because capability references can only be string paths.","triggerScenarios":"Calling `generate_context!` with `capabilities = [<non-string>]`, e.g. `capabilities = [include_str!(\"...\")]`, a variable name, or a numeric literal inside the array.","commonSituations":"Developers trying to dynamically build the capabilities list (via macros, include_str, or constants) inside the attribute; typos leaving off quotes around a path.","solutions":["Make every element of the capabilities array a plain string literal, e.g. capabilities = [\"capabilities/default\"]","Move dynamic path construction outside the macro and reference files by static string paths","If you need many capabilities, use a directory entry (a path ending in /*) as a string instead of generating entries programmatically"],"exampleFix":"// before\ntauri::generate_context!(\n  \"tauri.conf.json\",\n  capabilities = [include_str!(\"../capabilities/main.json\")]\n)\n// after\ntauri::generate_context!(\n  \"tauri.conf.json\",\n  capabilities = [\"../capabilities/main.json\"]\n)","handlingStrategy":"validation","validationCode":"// Before invoking generate_context!, ensure capabilities entries are string literals.\nconst CAPABILITIES: &[&str] = &[\"../capabilities/main.json\"];\nassert!(CAPABILITIES.iter().all(|c| !c.is_empty()), \"capabilities must be string paths\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never place non-literal expressions inside the capabilities array","Copy-paste a known-good generate_context! invocation when adding capabilities","Keep capability paths relative and quoted"],"tags":["compile-time","macro","capabilities","invalid-argument"],"backgroundTag":"invalid-argument-value","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"}