tauri-apps/tauri · error · syn::Error
unexpected value for capabilities
Error message
unexpected value for capabilities
What it means
A compile-time error from `tauri::generate_context!`. The `capabilities` attribute must be a name-value pair whose value is an array of string literals. Any other value shape (a single string, a parenthesized expression, a path, etc.) is rejected by the macro parser.
Solutions
- Wrap the value in an array of string literals: capabilities = ["capabilities/default"]
- Check the generate_context! attribute syntax in the Tauri docs
- If the intent is to declare capabilities, put them in the tauri.conf.json `app.security.capabilities` field instead
Example fix
// before
tauri::generate_context!("tauri.conf.json", capabilities = "default")
// after
tauri::generate_context!("tauri.conf.json", capabilities = ["default"]) Defensive patterns
Strategy: validation
Validate before calling
// capabilities value must be an array of strings
fn valid_capabilities(v: &str) -> bool {
let t = v.trim();
t.starts_with('[') && t.ends_with(']') && t.contains('"')
} Prevention
- Always use array syntax even for a single capability: capabilities = ["..."]
- Prefer declaring capabilities in tauri.conf.json instead of the macro
- Check docs for the exact macro syntax of your Tauri version
When it happens
Trigger: Writing `capabilities = "main"` (missing brackets) or `capabilities = foo()` inside a `generate_context!` invocation.
Common situations: Copy-pasting capability config from documentation that used a different syntax; forgetting the `[...]` array when only one capability file is listed.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- unexpected expression for capability
- unexpected list input
- default_runtime only supports `struct`, `enum`, `type`, or…
- ` ` env var not set, do you have a build script with…
- unexpected value for test
AI-assisted analysis of tauri-apps/tauri@460ec35447 (2026-09-18).
Data as JSON: /api/errors/c290daad9627182d.
Report an issue: GitHub.
Appendix: 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 460ec35447)