google/python-fire · error · FireError
Could not consume arg:
Error message
Could not consume arg:
What it means
During traversal, Fire consumes args one at a time by matching them against members (attributes/methods) of the current component. If an argument token cannot be consumed — it matches no accessible member, isn't callable consumable, and isn't a flag — FireError('Could not consume arg:', arg) is raised and recorded in the trace.
Source
Thrown at fire/core.py:649
Returns:
component: The component that was found by consuming an arg.
consumed_args: The args that were consumed by getting this member.
remaining_args: The remaining args that haven't been consumed yet.
Raises:
FireError: If we cannot consume an argument to get a member.
"""
members = dir(component)
arg = args[0]
arg_names = [
arg,
arg.replace('-', '_'), # treat '-' as '_'.
]
for arg_name in arg_names:
if arg_name in members:
return getattr(component, arg_name), [arg], args[1:]
raise FireError('Could not consume arg:', arg)
def _CallAndUpdateTrace(component, args, component_trace, treatment='class',
target=None):
"""Call the component by consuming args from args, and update the FireTrace.
The component could be a class, a routine, or a callable object. This function
calls the component and adds the appropriate action to component_trace.
Args:
component: The component to call
args: Args for calling the component
component_trace: FireTrace object that contains action trace
treatment: Type of treatment used. Indicating whether we treat the component
as a class, a routine, or a callable.
target: Target in FireTrace element, default is None. If the value is None,
the component itself will be used as target.
Returns:View on GitHub (pinned to 716bbc23d7)
Solutions
- Check spelling/case of the argument against the component's members
- Use `mytool -- --help` to list available members
- Expose the needed attribute/method as public
- Pass the value as a flag (--name value) if it was meant as an argument
Example fix
// before $ mytool statrt # typo // after $ mytool start
Defensive patterns
Strategy: validation
Validate before calling
args = sys.argv[1:]
missing = [a for a in args if not a.startswith('-') and not hasattr(component, a)]
# note: only meaningful for the first traversal token; prefer --help for full check Try / catch
try:
fire.Fire(component)
except fire.core.FireError as e:
if 'Could not consume arg' in str(e):
print('Unknown command; see -- --help', file=sys.stderr)
sys.exit(2)
raise Prevention
- Run `tool -- --help` to see available members before invoking
- Keep subcommand names public and consistently cased
- Add regression tests for each documented subcommand name
When it happens
Trigger: Typo in a subcommand name (mytool stat vs mytool start); passing a positional arg to an object whose members don't include it; accessing a private/mangled attribute that isn't in members; passing a bare value where a method name is expected.
Common situations: Renamed methods after refactoring; case-sensitivity mistakes; trying to access dict-like keys on an object that only supports attribute access.
Related errors
- Given file path does not exist.
- Unable to load module from specified path.
- Fire can only be called on .py files.
- Fire was passed a filename which could not be found.
- The command argument must be a string or a sequence of argum
AI-assisted analysis of google/python-fire@716bbc23d7 (2026-08-28).
Data as JSON: /api/errors/9a0a53f4dd91d9b4.
Report an issue: GitHub.