{"record":{"id":"94cbabe62bb3d43a","repo":"google/python-fire","slug":"the-function-received-no-value-for-the-required-ar","errorCode":null,"errorMessage":"The function received no value for the required argument:","messagePattern":"The function received no value for the required argument:","errorType":"exception","errorClass":"FireError","httpStatus":null,"severity":"error","filePath":"fire/core.py","lineNumber":807,"sourceCode":"  \"\"\"\n  accepts_positional_args = metadata.get(decorators.ACCEPTS_POSITIONAL_ARGS)\n  capacity = False  # If we see a default get used, we'll set capacity to True\n\n  # Select unnamed args.\n  parsed_args = []\n  for index, arg in enumerate(fn_args):\n    value = kwargs.pop(arg, None)\n    if value is not None:  # A value is specified at the command line.\n      value = _ParseValue(value, index, arg, metadata)\n      parsed_args.append(value)\n    else:  # No value has been explicitly specified.\n      if remaining_args and accepts_positional_args:\n        # Use a positional arg.\n        value = remaining_args.pop(0)\n        value = _ParseValue(value, index, arg, metadata)\n        parsed_args.append(value)\n      elif index < num_required_args:\n        raise FireError(\n            'The function received no value for the required argument:', arg)\n      else:\n        # We're past the args for which there's no default value.\n        # There's a default value for this arg.\n        capacity = True\n        default_index = index - num_required_args  # index into the defaults.\n        parsed_args.append(fn_defaults[default_index])\n\n  for key, value in kwargs.items():\n    kwargs[key] = _ParseValue(value, None, key, metadata)\n\n  return parsed_args, kwargs, remaining_args, capacity\n\n\ndef _ParseKeywordArgs(args, fn_spec):\n  \"\"\"Parses the supplied arguments for keyword arguments.\n\n  Given a list of arguments, finds occurrences of --name value, and uses 'name'","sourceCodeStart":789,"sourceCodeEnd":825,"githubUrl":"https://github.com/google/python-fire/blob/716bbc23d7eca949fdb682172283c8d18f742cb6/fire/core.py#L789-L825","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Pass the missing positional argument: mytool greet Alice","Give the parameter a default in the function signature","Quote/escape arguments in shell so empty values are still passed","Make the parameter keyword-only or optional"],"exampleFix":"// before\ndef greet(name): ...  # invoked: mytool greet\n// after\n$ mytool greet Alice   # or: def greet(name='world'): ...","handlingStrategy":"validation","validationCode":"spec = inspect.fullargspec if False else __import__('inspect').signature(fn)\nrequired = [n for n, p in spec.parameters.items()\n            if p.kind in (p.POSITIONAL_ONLY, p.POSITIONAL_OR_KEYWORD) and p.default is p.empty]\nif len(positional_supplied) < len(required):\n    raise TypeError(f'missing required args: {required[len(positional_supplied):]}')","typeGuard":null,"tryCatchPattern":"try:\n    fire.Fire(component)\nexcept fire.core.FireError as e:\n    if 'no value for the required argument' in str(e):\n        print('missing positional argument; see -- --help', file=sys.stderr)\n        sys.exit(2)\n    raise","preventionTips":["Quote shell args so empty values still count: mytool greet \"$NAME\"","Give defaults to optional parameters","Add a smoke test invoking each command with its minimum args"],"tags":["python","cli","missing-argument","positional"],"backgroundTag":"missing-required-argument","analyzedSha":"716bbc23d7eca949fdb682172283c8d18f742cb6","analyzedAt":"2026-08-28T21:57:47.200Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}