google/python-fire · error · FireError

The function received no value for the required argument:

Error message

The function received no value for the required argument:

What it means

Fire maps remaining positional args onto the callable's parameters that lack defaults. If all remaining args are exhausted while a required (no-default) parameter is still unfilled, FireError('The function received no value for the required argument:', arg) is raised naming the parameter.

Source

Thrown at fire/core.py:807

  """
  accepts_positional_args = metadata.get(decorators.ACCEPTS_POSITIONAL_ARGS)
  capacity = False  # If we see a default get used, we'll set capacity to True

  # Select unnamed args.
  parsed_args = []
  for index, arg in enumerate(fn_args):
    value = kwargs.pop(arg, None)
    if value is not None:  # A value is specified at the command line.
      value = _ParseValue(value, index, arg, metadata)
      parsed_args.append(value)
    else:  # No value has been explicitly specified.
      if remaining_args and accepts_positional_args:
        # Use a positional arg.
        value = remaining_args.pop(0)
        value = _ParseValue(value, index, arg, metadata)
        parsed_args.append(value)
      elif index < num_required_args:
        raise FireError(
            'The function received no value for the required argument:', arg)
      else:
        # We're past the args for which there's no default value.
        # There's a default value for this arg.
        capacity = True
        default_index = index - num_required_args  # index into the defaults.
        parsed_args.append(fn_defaults[default_index])

  for key, value in kwargs.items():
    kwargs[key] = _ParseValue(value, None, key, metadata)

  return parsed_args, kwargs, remaining_args, capacity


def _ParseKeywordArgs(args, fn_spec):
  """Parses the supplied arguments for keyword arguments.

  Given a list of arguments, finds occurrences of --name value, and uses 'name'

View on GitHub (pinned to 716bbc23d7)

Solutions

  1. Pass the missing positional argument: mytool greet Alice
  2. Give the parameter a default in the function signature
  3. Quote/escape arguments in shell so empty values are still passed
  4. Make the parameter keyword-only or optional

Example fix

// before
def greet(name): ...  # invoked: mytool greet
// after
$ mytool greet Alice   # or: def greet(name='world'): ...
Defensive patterns

Strategy: validation

Validate before calling

spec = inspect.fullargspec if False else __import__('inspect').signature(fn)
required = [n for n, p in spec.parameters.items()
            if p.kind in (p.POSITIONAL_ONLY, p.POSITIONAL_OR_KEYWORD) and p.default is p.empty]
if len(positional_supplied) < len(required):
    raise TypeError(f'missing required args: {required[len(positional_supplied):]}')

Try / catch

try:
    fire.Fire(component)
except fire.core.FireError as e:
    if 'no value for the required argument' in str(e):
        print('missing positional argument; see -- --help', file=sys.stderr)
        sys.exit(2)
    raise

Prevention

When it happens

Trigger: Invoking `mytool greet` where greet(name) needs one positional arg; passing an empty quoted string in a way that gets consumed as a flag separator; a flag with a value consuming what was meant to be positional input.

Common situations: Forgetting to pass a mandatory CLI argument; shell scripts dropping empty variables ($VAR unset becomes zero args); signature changes that added a new required parameter.

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


AI-assisted analysis of google/python-fire@716bbc23d7 (2026-08-28). Data as JSON: /api/errors/94cbabe62bb3d43a. Report an issue: GitHub.