{"record":{"id":"a5a36f83facdcfef","repo":"google/python-fire","slug":"cannot-make-completion-script-without-command-name","errorCode":null,"errorMessage":"Cannot make completion script without command name","messagePattern":"Cannot make completion script without command name","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"fire/core.py","lineNumber":599,"sourceCode":"      elif component is not last_component:\n        remaining_args = [separator] + saved_args\n      else:\n        # It was an unnecessary separator.\n        remaining_args = saved_args\n\n    if component is last_component and remaining_args == initial_args:\n      # We're making no progress.\n      break\n\n  if remaining_args:\n    component_trace.AddError(\n        FireError('Could not consume arguments:', remaining_args),\n        initial_args)\n    return component_trace\n\n  if show_completion is not None:\n    if name is None:\n      raise ValueError('Cannot make completion script without command name')\n    script = CompletionScript(name, initial_component, shell=show_completion)\n    component_trace.AddCompletionScript(script)\n\n  if interactive:\n    variables = context.copy()\n\n    if name is not None:\n      variables[name] = initial_component\n    variables['component'] = initial_component\n    variables['result'] = component\n    variables['trace'] = component_trace\n\n    if instance is not None:\n      variables['self'] = instance\n\n    interact.Embed(variables, verbose)\n\n    component_trace.AddInteractiveMode()","sourceCodeStart":581,"sourceCodeEnd":617,"githubUrl":"https://github.com/google/python-fire/blob/716bbc23d7eca949fdb682172283c8d18f742cb6/fire/core.py#L581-L617","documentation":"Requesting a completion script (-- --completion [shell]) requires knowing the installed command name so the generated script can hook into it. If fire.Fire() is called without the `name` parameter while completion is requested, this ValueError is raised.","triggerScenarios":"Running `mytool -- --completion bash` when the entry was fire.Fire(component) with no name= argument; calling fire.Fire(component, show_completion='bash') programmatically with name=None.","commonSituations":"Tools installed via console_scripts that forgot to pass name=__file__ or the command name; tests invoking Fire without a name but exercising completion.","solutions":["Pass the command name: fire.Fire(component, name='mytool')","Use fire.Fire(component=component, name=str(sys.argv[0])) or the module name in the entry point","Avoid -- --completion when no name is provided"],"exampleFix":"// before\nfire.Fire(component)  # user runs: mytool -- --completion bash\n// after\nfire.Fire(component, name='mytool')","handlingStrategy":"validation","validationCode":"if show_completion and name is None:\n    raise ValueError('pass name= to fire.Fire to enable --completion')","typeGuard":null,"tryCatchPattern":"try:\n    fire.Fire(component, name=name)\nexcept ValueError as e:\n    if 'completion script' in str(e):\n        sys.exit('completion requires name=')\n    raise","preventionTips":["Always pass name='yourcmd' in console_script entry points","Smoke-test `yourcmd -- --completion bash` in CI","Derive name from sys.argv[0] if hardcoded names are undesirable"],"tags":["python","cli","completion","configuration"],"backgroundTag":"missing-required-parameter","analyzedSha":"716bbc23d7eca949fdb682172283c8d18f742cb6","analyzedAt":"2026-08-28T21:57:47.200Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}