Skip to content

explain command causes exception if no fixes applied #12

@drdavella

Description

@drdavella

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions