tauri-apps/tauri · error · syn::Error
unexpected value for capabilities
Error message
unexpected value for capabilities
What it means
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'.
Source
Thrown at crates/tauri-macros/src/context.rs:89
.into_iter()
.map(|e| {
if let Expr::Lit(ExprLit {
attrs: _,
lit: Lit::Str(s),
}) = e
{
Ok(s.value().into())
} else {
Err(syn::Error::new(
input.span(),
"unexpected expression for capability",
))
}
})
.collect::<Result<Vec<_>, syn::Error>>()?,
);
} else {
return Err(syn::Error::new(
input.span(),
"unexpected value for capabilities",
));
}
}
"assets" => {
assets.replace(v.value);
}
"test" => {
if let Expr::Lit(ExprLit {
lit: Lit::Bool(LitBool { value, .. }),
..
}) = v.value
{
test = value;
} else {
return Err(syn::Error::new(input.span(), "unexpected value for test"));
}View on GitHub (pinned to 52e4b6e71d)
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
Example fix
// before #[tauri::generate_context(capabilities = "core:default")] // after #[tauri::generate_context(capabilities = ["core:default"])]
Defensive patterns
Strategy: validation
Prevention
- 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
When it happens
Trigger: #[tauri::generate_context(capabilities = "core:default")] (string instead of array), or capabilities = CAPABILITIES where CAPABILITIES is a const Vec/&[&str].
Common situations: Shorthand thinking where one capability is written without brackets; refactoring shared capability lists into consts; JSON-style single values copied from tauri.conf.json.
Related errors
- unexpected expression for capability
- unexpected value for test
- unknown attribute {name}
- unexpected list input
- unexpected list input
AI-assisted analysis of tauri-apps/tauri@52e4b6e71d (2026-08-20).
Data as JSON: /api/errors/c290daad9627182d.
Report an issue: GitHub.