Skip to content

'pulp domain' leads to a stack trace when a default value for --domain is provided in the config file. #769

Closed

Description

@MichalPysik

When writing 'pulp' in the cli, 'domain' shows as one of the available commands, but entering 'pulp domain (...)' always leads to a Python traceback. Right way to access pulp domain commands is typing 'pulp domains (...)'.

Typing 'pulp domains' shows a valid domain menu, so the problem applies to the top-level help list.

edit:
It's a conflict between --domain and domain and the way click handles default_maps for child contexts.
https://click.palletsprojects.com/en/8.1.x/commands/#overriding-defaults: "The default map can be nested arbitrarily for each subcommand:"
Long story short, if you remove the "domain" entry from the config file (that is where the string comes from that it later tries to use as a new default_map), we are fine again.

Activity

  1. added
    bug
    Triage-Needed
    on Aug 11, 2023
  2. added
    invalid
    and removed
    bug
    Triage-Needed
    on Aug 11, 2023
  3. mdellweg commented on Aug 11, 2023

    @mdellweg
    Member

    pulp domain is the proper command.

    $ pulp domains --help
    Please use 'domain' instead of 'domains'.
    [...]
  4. ggainey commented on Aug 11, 2023

    @ggainey
    Contributor

    pulp domains was the original implementation, but that doesn't follow the pulp-cli pattern (command should be singular not plural). domains was left as an alias when we fixed it, but will be removed Real Soon Now.

  5. MichalPysik commented on Aug 11, 2023

    @MichalPysik
    ContributorAuthor
    [michal@fedora Pulp]$ pulp domains
    Please use 'domain' instead of 'domains'.
    Usage: pulp domains [OPTIONS] COMMAND [ARGS]...
    
      Perform actions on domains.
    
    Options:
      --help  Show this message and exit.
    
    Commands:
      create
      destroy
      list
      role
      show
      update
    
    
    
    
    [michal@fedora Pulp]$ pulp domain
    Traceback (most recent call last):
      File "/home/michal/.local/bin/pulp", line 8, in <module>
        sys.exit(main())
      File "/home/michal/Desktop/Pulp/pulp-cli/pulp_cli/__init__.py", line 33, in main
        return _main()
      File "/usr/lib/python3.10/site-packages/click/core.py", line 1128, in __call__
        return self.main(*args, **kwargs)
      File "/usr/lib/python3.10/site-packages/click/core.py", line 1053, in main
        rv = self.invoke(ctx)
      File "/home/michal/Desktop/Pulp/pulp-cli/pulpcore/cli/common/generic.py", line 183, in invoke
        return super().invoke(ctx)
      File "/usr/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
        sub_ctx = cmd.make_context(cmd_name, args, parent=ctx)
      File "/usr/lib/python3.10/site-packages/click/core.py", line 914, in make_context
        self.parse_args(ctx, args)
      File "/usr/lib/python3.10/site-packages/click/core.py", line 1612, in parse_args
        echo(ctx.get_help(), color=ctx.color)
      File "/usr/lib/python3.10/site-packages/click/core.py", line 693, in get_help
        return self.command.get_help(self)
      File "/usr/lib/python3.10/site-packages/click/core.py", line 1295, in get_help
        self.format_help(ctx, formatter)
      File "/usr/lib/python3.10/site-packages/click/core.py", line 1326, in format_help
        self.format_options(ctx, formatter)
      File "/usr/lib/python3.10/site-packages/click/core.py", line 1523, in format_options
        super().format_options(ctx, formatter)
      File "/usr/lib/python3.10/site-packages/click/core.py", line 1346, in format_options
        rv = param.get_help_record(ctx)
      File "/usr/lib/python3.10/site-packages/click/core.py", line 2710, in get_help_record
        default_value = self.get_default(ctx, call=False)
      File "/usr/lib/python3.10/site-packages/click/core.py", line 2782, in get_default
        return super().get_default(ctx, call=call)
      File "/usr/lib/python3.10/site-packages/click/core.py", line 2210, in get_default
        value = ctx.lookup_default(self.name, call=False)  # type: ignore
      File "/usr/lib/python3.10/site-packages/click/core.py", line 658, in lookup_default
        value = self.default_map.get(name)
    AttributeError: 'str' object has no attribute 'get'
    
  6. MichalPysik commented on Aug 11, 2023

    @MichalPysik
    ContributorAuthor

    ^

    @ggainey @mdellweg I rebased to the latest cli version and this is still what both me and @lubosmj get.

  7. changed the title [-]'pulp domains' is misleadingly listed as 'pulp domain' in the help text[/-] [+]'pulp domain' leads to a stack trace when a default value for --domain is provided in the config file.[/+] on Aug 11, 2023
  8. added
    bug
    and removed
    invalid
    on Aug 11, 2023
  9. added a commit that references this issue on Aug 11, 2023
    a6d459b
  10. added a commit that references this issue on Aug 11, 2023
    aa48741
  11. added a commit that references this issue on Aug 11, 2023
    b035371
  12. added a commit that references this issue on Aug 11, 2023
    53c0ea3
  13. added a commit that references this issue on Jan 12, 2024
    800c718
  14. added a commit that references this issue on Jan 15, 2024
    6ec98d2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions