FuelLabs/fuels-rs · error · syn::Error
Unrecognized command. Expected one of: {msg}
Error message
Unrecognized command. Expected one of: {msg} What it means
Compile-time error from the setup_program_test macro's command parser: the first token of a command inside the macro invocation was matched against the fixed list of available commands (generated via stringify! of the macro's command list) and did not match any of them. The message lists every accepted command name for the invocation site.
Source
Thrown at packages/fuels-macros/src/setup_program_test/parsing/command_parser.rs:19
macro_rules! command_parser {
($($command_name: ident -> $command_struct: ty),+ $(,)?) => {
#[derive(Default)]
#[allow(non_snake_case)]
pub(crate) struct CommandParser {
$(pub(crate) $command_name: Vec<$command_struct>),*
}
impl CommandParser {
fn available_commands() -> impl Iterator<Item=&'static str> {
[$(stringify!($command_name)),*].into_iter()
}
pub(crate) fn parse_and_save(&mut self, command: $crate::parse_utils::Command) -> ::syn::Result<()>{
match command.name.to_string().as_str() {
$(stringify!($command_name) => self.$command_name.push(command.try_into()?),)*
_ => {
let msg = Self::available_commands().map(|command| format!("'{command}'")).join(", ");
return Err(::syn::Error::new(command.name.span(), format!("Unrecognized command. Expected one of: {msg}")));
}
};
Ok(())
}
}
impl Parse for CommandParser {
fn parse(input: ::syn::parse::ParseStream) -> Result<Self> {
use $crate::parse_utils::ErrorsExt;
let mut command_parser = Self::default();
let mut errors = vec![];
for command in $crate::parse_utils::Command::parse_multiple(input)? {
if let Err(error) = command_parser.parse_and_save(command) {
errors.push(error);
}
}
View on GitHub (pinned to d9a250a518)
Solutions
- Read the message: it enumerates the exact accepted commands ('Abigen', 'Wallets', 'DeployContract', ...).
- Fix the command identifier to match one from the list exactly (spelling and casing).
- If the command genuinely should exist, you are probably on a different SDK version — upgrade/downgrade to the version whose macro supports it, or restructure the test to use the runtime API instead.
- Keep one canonical example setup_program_test block as a template to avoid regressions.
Example fix
// before
setup_program_test!(
Wallets([wallet]),
DeployContract(name = "counter", salt = ...),
)
// after
setup_program_test!(
Wallets([wallet]),
DeployContract(name = "counter"),
) Defensive patterns
Strategy: validation
Prevention
- The error message enumerates valid commands — copy the exact identifier from it.
- Pin to one SDK version across the workspace so command vocabularies stay consistent.
- Watch casing: commands are CamelCase plurals like 'Wallets', not 'Wallet'.
When it happens
Trigger: Inside setup_program_test!(...), writing a command name that is not one of the registered ones — a typo (Wallet instead of Wallets), wrong casing (deployContract vs DeployContract), or a command that belongs to a different macro/version (e.g. using LoadScript syntax on a version where it is not registered).
Common situations: Copy-pasting setup blocks from older fuels versions whose command names changed; guessing command names instead of checking the list in the error; typos in camel-case command identifiers.
Related errors
- Only one `Abigen` command allowed
- Add an `Abigen(..)` command!
- Consider adding: Contract(name="{}", project=...)
- Consider adding: Script(name="{}", project=...)
- Only one `Wallets` command allowed
AI-assisted analysis of FuelLabs/fuels-rs@d9a250a518 (2026-08-16).
Data as JSON: /api/errors/d382588a8026f35f.
Report an issue: GitHub.