google/python-fire · error · FireError
Missing required flags:
Error message
Missing required flags:
What it means
Python keyword-only parameters without defaults (required_kwonly) must be supplied by the caller. Fire raises FireError('Missing required flags:', missing_kwonly) naming the flags that were not provided when calling the function through the CLI.
Source
Thrown at fire/core.py:743
"""Parses the list of `args` into (varargs, kwargs), remaining_args."""
kwargs, remaining_kwargs, remaining_args = _ParseKeywordArgs(args, fn_spec)
# Note: _ParseArgs modifies kwargs.
parsed_args, kwargs, remaining_args, capacity = _ParseArgs(
fn_spec.args, fn_spec.defaults, num_required_args, kwargs,
remaining_args, metadata)
if fn_spec.varargs or fn_spec.varkw:
# If we're allowed *varargs or **kwargs, there's always capacity.
capacity = True
extra_kw = set(kwargs) - set(fn_spec.kwonlyargs)
if fn_spec.varkw is None and extra_kw:
raise FireError('Unexpected kwargs present:', extra_kw)
missing_kwonly = set(required_kwonly) - set(kwargs)
if missing_kwonly:
raise FireError('Missing required flags:', missing_kwonly)
# If we accept *varargs, then use all remaining arguments for *varargs.
if fn_spec.varargs is not None:
varargs, remaining_args = remaining_args, []
else:
varargs = []
for index, value in enumerate(varargs):
varargs[index] = _ParseValue(value, None, None, metadata)
varargs = parsed_args + varargs
remaining_args += remaining_kwargs
consumed_args = args[:len(args) - len(remaining_args)]
return (varargs, kwargs), consumed_args, remaining_args, capacity
return _ParseFn
View on GitHub (pinned to 716bbc23d7)
Solutions
- Supply the missing flag: mytool run --required_a=value
- Give the parameter a default value in the signature
- Wrap with a check in the component to produce a friendlier message
Example fix
// before def deploy(*, env): ... # invoked: deploy // after $ deploy --env=prod # or: def deploy(*, env='dev'): ...
Defensive patterns
Strategy: validation
Validate before calling
spec = inspect.signature(fn)
missing = [n for n, p in spec.parameters.items()
if p.kind == p.KEYWORD_ONLY and p.default is p.empty and n not in supplied]
if missing:
raise TypeError(f'missing required flags: {missing}') Try / catch
try:
fire.Fire(component)
except fire.core.FireError as e:
if 'Missing required flags' in str(e):
print('supply required flags; see -- --help', file=sys.stderr)
sys.exit(2)
raise Prevention
- Provide defaults for keyword-only params when feasible
- Validate required flags in wrapper scripts before invoking the CLI
- Document required flags and test invocations in CI
When it happens
Trigger: Calling fn(*, required_a, required_b=2) without passing --required_a; programmatic Fire usage constructing kwargs that omit a required keyword-only arg.
Common situations: Functions converted to keyword-only args (after the * in signature) that scripts still call positionally; CI invocations missing flags that a developer passes interactively.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- The function received no value for the required argument:
- 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.
AI-assisted analysis of google/python-fire@716bbc23d7 (2026-08-28).
Data as JSON: /api/errors/d3a49a1b5e177d80.
Report an issue: GitHub.