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

bug: ctl: handle non-existing bot modules #2443

Merged
merged 2 commits into from
Feb 8, 2024
Merged

Conversation

sebix
Copy link
Member

@sebix sebix commented Dec 29, 2023

the new function utils.get_bot_module_name returns None if a bot module does not exist, and
importlib.import_module raises an exception when passed None

I added no changelog entry as the faulty code was never released.

previously:

Checking for bots.
Traceback (most recent call last):
  File "/usr/bin/intelmqctl", line 33, in <module>
    sys.exit(load_entry_point('intelmq==3.2.2a1', 'console_scripts', 'intelmqctl')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/intelmq/bin/intelmqctl.py", line 1295, in main
    return x.run()
           ^^^^^^^
  File "/usr/lib/python3.11/site-packages/intelmq/bin/intelmqctl.py", line 429, in run
    retval, results = args.func(**args_dict)
                      ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/intelmq/bin/intelmqctl.py", line 934, in check
    bot_module = importlib.import_module(utils.get_bot_module_name(bot_config['module']))
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/importlib/__init__.py", line 117, in import_module
    if name.startswith('.'):
       ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'startswith'

now:

Checking for bots.
Incomplete installation: Bot 'malc0de-parser' not importable.

the new function utils.get_bot_module_name returns None if a bot module
does not exist, and
importlib.import_module raises an exception when passed None
@sebix sebix added bug Indicates an unexpected problem or unintended behavior component: core labels Dec 29, 2023
@sebix sebix added this to the 3.2.2 milestone Dec 29, 2023
@sebix
Copy link
Member Author

sebix commented Dec 29, 2023

The one check that fails, fails consistently, but for no apparent reason. I already re-ran it with the same result. I has nothing to do with the changed code and it makes no sense that this test only fails on one platform too:

=================================== FAILURES ===================================
__________________________ TestAmqp.test_acknowledge ___________________________

self = <intelmq.tests.lib.test_pipeline.TestAmqp testMethod=test_acknowledge>

    @unittest.skipIf(os.getenv('CI') == 'true' and sys.version_info[:2] == (3, 8),
                     'Fails on CI with Python 3.8')
    def test_acknowledge(self):
        self.pipe.send(SAMPLES['normal'][0])
        self.pipe.receive()
        self.pipe.acknowledge()
>       self.assertEqual(self.pipe.count_queued_messages('test')['test'], 0)
E       AssertionError: 1 != 0

intelmq/tests/lib/test_pipeline.py:275: AssertionError
------------------------------ Captured log call -------------------------------
WARNING  pika.channel:channel.py:238 basic_cancel - consumer not found: ctag1.3ba5f52b9bf64f68b7debd8cd4b8e790

Copy link
Contributor

@kamil-certat kamil-certat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch

@kamil-certat
Copy link
Contributor

re: CI fail - please mark it as skipped and create an issue to investigate it

@aaronkaplan
Copy link
Member

Thank you @sebix !

@aaronkaplan aaronkaplan merged commit ac6aa4e into develop Feb 8, 2024
31 checks passed
@sebix sebix deleted the fix-check-import branch February 8, 2024 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior component: core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants