Skip to content

fix(general): CRASH add exception handling for logging configuration#7460

Open
scottschreckengaust wants to merge 3 commits intobridgecrewio:mainfrom
scottschreckengaust:log-level-protection
Open

fix(general): CRASH add exception handling for logging configuration#7460
scottschreckengaust wants to merge 3 commits intobridgecrewio:mainfrom
scottschreckengaust:log-level-protection

Conversation

@scottschreckengaust
Copy link
Copy Markdown

@scottschreckengaust scottschreckengaust commented Mar 10, 2026

Handle exceptions for invalid log levels defaulting to WARNING.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Description

If the environmental variable LOG_LEVEL was not a valid Python value, checkov would crash with:

ValueError: Unknown level

Fixes #7459

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my feature, policy, or fix is effective and works
  • New and existing tests pass locally with my changes

Handle exceptions for invalid log levels defaulting to `WARNING`.
@scottschreckengaust scottschreckengaust changed the title fix: add exception handling for logging configuration [WIP] fix: add exception handling for logging configuration Mar 11, 2026
Signed-off-by: Scott Schreckengaust <345885+scottschreckengaust@users.noreply.github.com>
Signed-off-by: Scott Schreckengaust <345885+scottschreckengaust@users.noreply.github.com>
@scottschreckengaust
Copy link
Copy Markdown
Author

% pytest tests/logger_streams/test_logging_init.py
/home/scoschre/github.com/scottschreckengaust/checkov/.venv/lib/python3.10/site-packages/pytest_benchmark/logger.py:39: PytestBenchmarkWarning: Benchmarks are automatically disabled because xdist plugin is active.Benchmarks cannot be performed reliably in a parallelized environment.
  warner(PytestBenchmarkWarning(text))
=================================================== test session starts ====================================================
platform linux -- Python 3.10.17, pytest-7.4.4, pluggy-1.6.0
benchmark: 5.0.1 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: /home/scoschre/github.com/scottschreckengaust/checkov
configfile: pyproject.toml
plugins: mock-3.15.1, asyncio-0.23.8, time-machine-2.19.0, cov-6.3.0, benchmark-5.0.1, xdist-3.8.0
asyncio: mode=strict
2 workers [10 items]    
..........                                                                                                           [100%]
==================================================== 10 passed in 3.70s ====================================================
% pre-commit run -a
debug statements (python)................................................Passed
flake8...................................................................Passed
teyit....................................................................Passed
Lint GitHub Actions workflow files.......................................Passed
pipenv-setup.............................................................Passed
import-linter............................................................Passed

@scottschreckengaust scottschreckengaust marked this pull request as ready for review March 11, 2026 01:01
@scottschreckengaust scottschreckengaust changed the title [WIP] fix: add exception handling for logging configuration fix: add exception handling for logging configuration Mar 11, 2026
@scottschreckengaust scottschreckengaust changed the title fix: add exception handling for logging configuration fix: CRASH add exception handling for logging configuration Mar 11, 2026
@scottschreckengaust scottschreckengaust changed the title fix: CRASH add exception handling for logging configuration fix(general): CRASH add exception handling for logging configuration Mar 11, 2026
@mayblo
Copy link
Copy Markdown
Contributor

mayblo commented Mar 17, 2026

Hi!

Can you check the failing jobs?

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.

Crash on unrecognized LOG_LEVEL environment variable (e.g. TRACE)

2 participants