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

explain command causes exception if no fixes applied #12

Open
drdavella opened this issue Jan 4, 2024 · 0 comments
Open

explain command causes exception if no fixes applied #12

drdavella opened this issue Jan 4, 2024 · 0 comments

Comments

@drdavella
Copy link
Member

When running pixee explain on an empty result set, the following exception occurs:

$ pixee explain
Reading results from `results.codetf.json`
No changes applied
Traceback (most recent call last):
  File "/opt/homebrew/bin/pixee", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/opt/homebrew/Cellar/pixee/0.5.5/libexec/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/pixee/0.5.5/libexec/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/pixee/0.5.5/libexec/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/pixee/0.5.5/libexec/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/pixee/0.5.5/libexec/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/pixee/0.5.5/libexec/lib/python3.11/site-packages/pixee/cli.py", line 388, in explain
    codemod := select(
               ^^^^^^^
  File "/opt/homebrew/Cellar/pixee/0.5.5/libexec/lib/python3.11/site-packages/questionary/prompts/select.py", line 133, in select
    raise ValueError("A list of choices needs to be provided.")
ValueError: A list of choices needs to be provided.

There are probably two changes we should make for this fix:

  1. Ensure that pixee explain exits cleanly without an exception in the case of an empty CodeTF file
  2. Do not generate a CodeTF file if pixee fix does not generate any fixes. This would help ensure that the last actual fix results remain available for pixee explain where applicable.
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