Repository navigation
fix: raise RuntimeError from get_request_logger before request instrumentation - #139
Conversation
…mentation get_request_logger() read the configurator's _instance attribute, which only exists after the configurator has been instantiated, so calling it after init_<framework>() but before init_request_instrument() raised AttributeError instead of the intended RuntimeError. Signed-off-by: Srinivas Chippagiri <cvas22@gmail.com>
|
ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing |
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Handle and test uninitialized request logger json_logging/__init__.py, tests/test_get_request_logger.py, CHANGELOG.md |
The function handles a missing configurator instance by raising the existing initialization error. A test verifies the error, and the changelog documents the fix. |
Priority:
Estimated code review effort: 2 (Simple) | ~5 minutes
Change: Bug fix
Possibly related issues
- Issue 137 identifies missing test coverage for
get_request_logger()before request instrumentation. This change adds that coverage and fixes the expectedRuntimeErrorbehavior.
Suggested reviewers: bobbui
Merge Risk: 
Minimal · up to a551e
-
The narrowly scoped logger initialization fix is mergeable.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passedFull details: Docstring Coverage
-
Explanation
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. (1 skipped: 1 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches: 💡 1
-
📝 Generate docstrings: 💡
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
Problem: after
init_flask()(or any framework init) but beforeinit_request_instrument(),get_request_logger()raisesAttributeError: type object ... has no attribute '_instance'instead of the intendedRuntimeError("please init request instrument first ...").Root cause:
_instanceis only set on the configurator class the first time it is instantiated, and the function read it directly.Fix: read it with
getattr(..., '_instance', None), so the existingNonecheck produces the intended error.Tests: new
tests/test_get_request_logger.pyfails before the change and passes after. Full unit suite (excluding smoke tests and gunicorn): 96 passed on Python 3.14.6, Windows.Found while working on #137.
Summary by CodeRabbit
get_request_logger()before request instrumentation is initialized now raises the documentedRuntimeErrorinstead of anAttributeError.