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

"safety generate/validate --help" fails with traceback #664

Open
1 task done
andy-maier opened this issue Jan 5, 2025 · 1 comment
Open
1 task done

"safety generate/validate --help" fails with traceback #664

andy-maier opened this issue Jan 5, 2025 · 1 comment

Comments

@andy-maier
Copy link

Checklist

Safety version

3.2.14

Python version

3.12.7

Operating System

macOS 14.7.2

Describe the problem you'd like to have solved

Some uses of the --help option cause a failure with traceback. It happened for me with safety validate --help and safety generate --help, but I did not test all safety subcommands.

Describe the ideal solution

--help should not fail.

Alternatives and current workarounds

No response

Additional context

No response

What I Did

$ safety generate --help
(zhmc312) maiera-mbp-3:python-zhmcclient maiera$ safety generate --help

 Generate a boilerplate Safety CLI policy file for customized security policies.                                                                                                                  
 Note: Safety Platform policies will override any local policy files found                                                                                                                        
 Example: safety generate policy_file                                                                                                                                                             
                                                                                                                                                                                                  
 Usage: safety generate [OPTIONS] NAME                                                                                                                                                            
                                                                                                                                                                                                  
                                           Options                                            
┏━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃            ┃                                                                               ┃
┡━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ ['--path'] │ The path where the generated file will be saved (default: current directory). │
│            │                                                                               │
│            │ Example: safety generate policy_file --path .my-project-safety-policy.yml     │
├────────────┼───────────────────────────────────────────────────────────────────────────────┤
│ ['--help'] │ Show this message and exit.                                                   │
└────────────┴───────────────────────────────────────────────────────────────────────────────┘
Traceback (most recent call last):
  File "/Users/maiera/virtualenvs/zhmc312/bin/safety", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/Users/maiera/virtualenvs/zhmc312/lib/python3.12/site-packages/click/core.py", line 1161, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/maiera/virtualenvs/zhmc312/lib/python3.12/site-packages/click/core.py", line 1082, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/Users/maiera/virtualenvs/zhmc312/lib/python3.12/site-packages/safety/cli_util.py", line 734, in invoke
    super(SafetyCLILegacyGroup, self).invoke(ctx)
  File "/Users/maiera/virtualenvs/zhmc312/lib/python3.12/site-packages/click/core.py", line 1695, in invoke
    sub_ctx = cmd.make_context(cmd_name, args, parent=ctx)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/maiera/virtualenvs/zhmc312/lib/python3.12/site-packages/click/core.py", line 949, in make_context
    self.parse_args(ctx, args)
  File "/Users/maiera/virtualenvs/zhmc312/lib/python3.12/site-packages/click/core.py", line 1417, in parse_args
    value, args = param.handle_parse_result(ctx, opts, args)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/maiera/virtualenvs/zhmc312/lib/python3.12/site-packages/click/core.py", line 2403, in handle_parse_result
    value = self.process_value(ctx, value)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/maiera/virtualenvs/zhmc312/lib/python3.12/site-packages/click/core.py", line 2365, in process_value
    value = self.callback(ctx, self, value)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/maiera/virtualenvs/zhmc312/lib/python3.12/site-packages/click/decorators.py", line 550, in show_help
    echo(ctx.get_help(), color=ctx.color)
         ^^^^^^^^^^^^^^
  File "/Users/maiera/virtualenvs/zhmc312/lib/python3.12/site-packages/click/core.py", line 711, in get_help
    return self.command.get_help(self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/maiera/virtualenvs/zhmc312/lib/python3.12/site-packages/click/core.py", line 1334, in get_help
    self.format_help(ctx, formatter)
  File "/Users/maiera/virtualenvs/zhmc312/lib/python3.12/site-packages/safety/cli_util.py", line 764, in format_help
    pretty_format_help(self, ctx, markup_mode="rich")
  File "/Users/maiera/virtualenvs/zhmc312/lib/python3.12/site-packages/safety/cli_util.py", line 245, in pretty_format_help
    custom_print_options_panel(
  File "/Users/maiera/virtualenvs/zhmc312/lib/python3.12/site-packages/safety/cli_util.py", line 39, in custom_print_options_panel
    table.add_row(str(param.opts), param.help or "")
                                   ^^^^^^^^^^
AttributeError: 'Argument' object has no attribute 'help'
Copy link

github-actions bot commented Jan 5, 2025

Hi @andy-maier, thank you for opening this issue!

We appreciate your effort in reporting this. Our team will review it and get back to you soon.
If you have any additional details or updates, feel free to add them to this issue.

Note: If this is a serious security issue that could impact the security of Safety CLI users, please email [email protected] immediately.

Thank you for contributing to Safety CLI!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant