{"record":{"id":"c290daad9627182d","repo":"tauri-apps/tauri","slug":"unexpected-value-for-capabilities","errorCode":null,"errorMessage":"unexpected value for capabilities","messagePattern":"unexpected value for capabilities","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"crates/tauri-macros/src/context.rs","lineNumber":89,"sourceCode":"                    .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\" => {\n              if let Expr::Lit(ExprLit {\n                lit: Lit::Bool(LitBool { value, .. }),\n                ..\n              }) = v.value\n              {\n                test = value;\n              } else {\n                return Err(syn::Error::new(input.span(), \"unexpected value for test\"));\n              }","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/tauri-apps/tauri/blob/52e4b6e71d8632a7e648f866c442e287ecddee34/crates/tauri-macros/src/context.rs#L71-L107","documentation":"The capabilities key of #[tauri::generate_context] must be an array expression (Expr::Array) whose elements are string literals. If the value is any other expression kind — a bare string, a const, a function call — the macro rejects the whole value with 'unexpected value for capabilities'.","triggerScenarios":"#[tauri::generate_context(capabilities = \"core:default\")] (string instead of array), or capabilities = CAPABILITIES where CAPABILITIES is a const Vec/&[&str].","commonSituations":"Shorthand thinking where one capability is written without brackets; refactoring shared capability lists into consts; JSON-style single values copied from tauri.conf.json.","solutions":["Wrap the value in an array of string literals: capabilities = [\"core:default\"]","Remove the key entirely to embed all capabilities found in src-tauri/capabilities","Keep in mind the attribute is evaluated at compile time: no runtime values are possible"],"exampleFix":"// before\n#[tauri::generate_context(capabilities = \"core:default\")]\n// after\n#[tauri::generate_context(capabilities = [\"core:default\"])]","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always wrap capabilities in [...]: capabilities = [\"core:default\"]","No consts or runtime values — the attribute is evaluated at compile time","Single-element lists still need the brackets"],"tags":["macros","generate-context","capabilities","compile-time","type-mismatch"],"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-14T00:17:10.932Z"}