block/buzz · error · syn::Error
expected `name`, `system`, or `fields`
Error message
expected `name`, `system`, or `fields`
What it means
The catch-all branch of #[datastore_span]'s argument parser: any key other than name, system, or fields produces 'expected `name`, `system`, or `fields`' at the offending identifier's span. It fires for typos, for unknown extras (e.g. trying target = ...), and for a `fields = ...` written with an equals sign — fields is parenthesized, so after `fields` the parser expects '(' and the '=' would be parsed as the next (unknown) key. Compile-time error.
Source
Thrown at crates/buzz-datastore-tracing/src/lib.rs:49
name = Some(input.parse()?);
}
"system" => {
if system.is_some() {
return Err(Error::new(key.span(), "duplicate `system` argument"));
}
input.parse::<Token![=]>()?;
system = Some(input.parse()?);
}
"fields" => {
if fields.is_some() {
return Err(Error::new(key.span(), "duplicate `fields` argument"));
}
let content;
parenthesized!(content in input);
fields = Some(content.parse()?);
}
_ => {
return Err(Error::new(
key.span(),
"expected `name`, `system`, or `fields`",
))
}
}
if !input.is_empty() {
input.parse::<Token![,]>()?;
}
}
Ok(Self {
name: name.ok_or_else(|| Error::new(input.span(), "missing `name`"))?,
system: system.ok_or_else(|| Error::new(input.span(), "missing `system`"))?,
fields,
})
}
}
View on GitHub (pinned to eed74bde2f)
Solutions
- Remove the unsupported key — the macro only accepts name, system, fields.
- If you wrote `fields = (...)`, drop the equals: `fields(...)`.
- For target/skip/level behaviour: it is already baked in (target = "buzz_datastore", skip_all, otel fields) — do not try to override.
- Check the doc comment on datastore_span for the accepted grammar before adding new arguments.
Example fix
// before #[datastore_span(name = "q", system = "postgresql", target = "my_target")] // after #[datastore_span(name = "q", system = "postgresql")] // target is always buzz_datastore
Defensive patterns
Strategy: validation
Validate before calling
// compile-time only: `cargo check` reports the unknown key's span; // accepted grammar: #[datastore_span(name = "...", system = "postgresql"[, fields(...)])]
Prevention
- The macro hardcodes target/skip behavior — never attempt to pass tracing::instrument options through it.
- fields uses parentheses, name/system use '='; internalize the asymmetry or copy a canonical example.
- Keep the doc comment on datastore_span in sync when the grammar changes so IDE hints stay accurate.
When it happens
Trigger: #[datastore_span(name = "q", system = "postgresql", targets = "x")] (typo/extra key), or #[datastore_span(..., fields = (a))] (wrong syntax — fields must be fields(a)), both hitting the _ => branch at crates/buzz-datastore-tracing/src/lib.rs:48-53.
Common situations: Trying to pass tracing::instrument-style options (target, level, skip) which this macro does not accept — it fixes target=buzz_datastore and skip_all itself; muscle memory typing `fields = (...)` after name/system which do use '='.
Related errors
- duplicate `name` argument
- duplicate `system` argument
- duplicate `fields` argument
- failed to install rustls crypto provider
- connect to test DB
AI-assisted analysis of block/buzz@eed74bde2f (2026-08-20).
Data as JSON: /api/errors/2a9a22ef4a651449.
Report an issue: GitHub.