Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
MichalPysik opened this issue Aug 11, 2023 · 4 comments · Fixed by #770
Labels
bug Something isn't working (template-set)

Comments

@MichalPysik
Copy link
Member

MichalPysik commented Aug 11, 2023

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.

@MichalPysik MichalPysik added bug Something isn't working (template-set) Triage-Needed Needs to be reviewed at next pulp-cli mtg labels Aug 11, 2023
@mdellweg mdellweg added invalid This request doesn't seem right and removed bug Something isn't working (template-set) Triage-Needed Needs to be reviewed at next pulp-cli mtg labels Aug 11, 2023
@mdellweg
Copy link
Member

mdellweg commented Aug 11, 2023

pulp domain is the proper command.

$ pulp domains --help
Please use 'domain' instead of 'domains'.
[...]

@mdellweg mdellweg closed this as not planned Won't fix, can't repro, duplicate, stale Aug 11, 2023
@ggainey
Copy link
Contributor

ggainey commented Aug 11, 2023

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.

@MichalPysik
Copy link
Member Author

MichalPysik commented Aug 11, 2023

[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'

@MichalPysik
Copy link
Member Author

^

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

@mdellweg mdellweg 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. Aug 11, 2023
@mdellweg mdellweg added bug Something isn't working (template-set) and removed invalid This request doesn't seem right labels Aug 11, 2023
@mdellweg mdellweg reopened this Aug 11, 2023
mdellweg added a commit to mdellweg/pulp-cli that referenced this issue Aug 11, 2023
Providing a default value for --domain lead to the domain subcommand
group getting an invalid default_map.

fixes pulp#769
mdellweg added a commit that referenced this issue Aug 11, 2023
Providing a default value for --domain lead to the domain subcommand
group getting an invalid default_map.

fixes #769
patchback bot pushed a commit that referenced this issue Aug 11, 2023
Providing a default value for --domain lead to the domain subcommand
group getting an invalid default_map.

fixes #769

(cherry picked from commit aa48741)
mdellweg added a commit that referenced this issue Aug 11, 2023
Providing a default value for --domain lead to the domain subcommand
group getting an invalid default_map.

fixes #769

(cherry picked from commit aa48741)
patchback bot pushed a commit that referenced this issue Jan 12, 2024
Providing a default value for --domain lead to the domain subcommand
group getting an invalid default_map.

fixes #769

(cherry picked from commit aa48741)
mdellweg added a commit that referenced this issue Jan 15, 2024
Providing a default value for --domain lead to the domain subcommand
group getting an invalid default_map.

fixes #769

(cherry picked from commit aa48741)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working (template-set)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants