Skip to content

Handle missing intelmqdump defaults#2703

Open
BharatDeva wants to merge 1 commit into
certtools:developfrom
BharatDeva:fix/intelmqdump-defaults-fallback
Open

Handle missing intelmqdump defaults#2703
BharatDeva wants to merge 1 commit into
certtools:developfrom
BharatDeva:fix/intelmqdump-defaults-fallback

Conversation

@BharatDeva
Copy link
Copy Markdown

Fixes #2702

Description

intelmqdump already handled failures while loading global settings by falling back to the default log level. However, the defaults variable was not initialized in that exception path, so the following logging setup could raise another exception before the tool had a chance to continue.

This change uses an empty defaults mapping when global settings cannot be loaded, and reuses the same mapping instead of calling get_global_settings() a second time immediately afterwards.

Tests

I ran the intelmqdump tests under WSL because the module imports Unix fcntl and cannot run on native Windows:

INTELMQ_TEST_INSTALLATION=1 PYTHONWARNINGS=ignore::PendingDeprecationWarning /home/codexuser/codex-work/intelmq/.venv/bin/python -m unittest intelmq.tests.bin.test_intelmqdump.TestIntelMQDump.test_list_dumps_when_defaults_cannot_be_loaded intelmq.tests.bin.test_intelmqdump.TestIntelMQDump.test_list_dumps_for_all_bots_from_default_log_path
# Ran 2 tests in 0.010s
# OK
INTELMQ_TEST_INSTALLATION=1 PYTHONWARNINGS=ignore::PendingDeprecationWarning /home/codexuser/codex-work/intelmq/.venv/bin/python -m unittest intelmq.tests.bin.test_intelmqdump
# Ran 9 tests in 0.093s
# OK

The /opt/intelmq/var/run/ permission messages are emitted by the existing controller setup in these tests; they were present while the tests completed successfully.

When loading global settings fails in an incomplete setup, intelmqdump falls back to the default log level but still needs an empty defaults mapping for later logging configuration. Reuse that mapping instead of loading the same settings a second time.

Add a regression test covering dump listing when global defaults cannot be loaded.

Signed-off-by: BharatDeva <278575558+BharatDeva@users.noreply.github.com>
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.

intelmqdump: exception when loading defaults fails

1 participant