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

Crash in 'about attrib' when rendering errors occur #575

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

arex-ebee
Copy link

Generating attribution file for a project that has erroneous ABOUT file(s) might lead to crash of the about script resulting in a Python backtrace:

$ about attrib --template <template_file> <base_dir> <attribution_file>
Running aboutcode-toolkit version 11.0.2
Generating attribution...
Traceback (most recent call last):
  File "aboutcode-toolkit/venv/bin/about", line 8, in <module>
    sys.exit(about())
             ^^^^^^^
  File "aboutcode-toolkit/venv/lib/python3.11/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "aboutcode-toolkit/venv/lib/python3.11/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "aboutcode-toolkit/venv/lib/python3.11/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "aboutcode-toolkit/venv/lib/python3.11/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "aboutcode-toolkit/venv/lib/python3.11/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "aboutcode-toolkit/src/attributecode/cmd.py", line 571, in attrib
    errors_count = report_errors(
                   ^^^^^^^^^^^^^^
  File "aboutcode-toolkit/src/attributecode/cmd.py", line 863, in report_errors
    log_msgs, severe_errors_count = get_error_messages(errors, verbose)
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "aboutcode-toolkit/src/attributecode/cmd.py", line 883, in get_error_messages
    severe_errors = filter_errors(errors, WARNING)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "aboutcode-toolkit/src/attributecode/util.py", line 635, in filter_errors
    return [e for e in errors if e.severity >= minimum_severity]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "aboutcode-toolkit/src/attributecode/util.py", line 635, in <listcomp>
    return [e for e in errors if e.severity >= minimum_severity]
                                 ^^^^^^^^^^
AttributeError: 'list' object has no attribute 'severity'

Root cause is that the final errors list not only contained elements of Error objects but also an additional embedded list of Error objects (e.g. [Error, Error, Error, [Error, Error, ...] ])

… list if a rendering error previously occured.

Signed-off-by: André <[email protected]>
Signed-off-by: André <[email protected]>
@pombredanne
Copy link
Member

Thanks!

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

Successfully merging this pull request may close these issues.

2 participants