Repository navigation
fix(logging): restore configured levels after suppression - #8215
Vidit Ostwal (Vidit-Ostwal) merged 2 commits into
Conversation
Strix Security ReviewWarning This pull request has 75 commits after the last Strix review ( No security issues found. Review summaryReviewed the logging-suppression fix in Updated for Reviewed by Strix |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to
|
|
This PR and issue #8214 were prepared with OpenAI Codex, as disclosed in both descriptions. My account cannot apply repository labels (HTTP 403). Could a maintainer please add |
2c9355c to
e63764d
Compare
|
Rebased onto current upstream main ( Revalidated on Python 3.13.15 with
Pytest used |
72a12d0 to
0062db8
Compare
0062db8 to
b155ff7
Compare
5d4f45b
into
crewAIInc:main
Thanks for your first contribution to CrewAI, lakers-abing!We really appreciate the time and care you put into this PR. Your work is now part of CrewAI — welcome to the contributor community. Want to share your contribution? Totally optional: Share on X · Share the PR on LinkedIn If the links don't work, feel free to copy and personalize this: If you share, we'd love to see it — tag crewAI (@crewAIInc) on X and CrewAI on LinkedIn. |
Related issue
Fixes #8214
Summary
Restore the logger's configured level when
suppress_logging()exits, including after exceptions and interruptions. Previously, a failed ChromaDB query could leave its logger atERROR, hiding subsequent warnings. Successful calls also replacedNOTSETwith the parent's current effective level, disabling later inheritance.Save
logger.leveland restore it infinally. Preserve the existing stdout/stderr redirection andUserWarningsuppression. Five regression cases cover normal exit, ordinary errors, interruption, and parent-level changes after inherited-level restoration.Verification
Tests added or updated for the changed behavior
Relevant tests and quality checks pass locally
Before the fix: 4 failed, 1 passed in
test_logger_utils.py.After the fix: 58 passed across that file and the existing ChromaDB suites.
Ruff check and format: passed for the changed source; formatting also checked for the test file.
Strict mypy on
logger_utils.py: passed.git diff --check: passed.Fresh Python 3.13.15 environment installed with
uv sync --locked --package crewai --group dev. Pytest used-n 0 -qand the repository's network block. A local launcher redirected import-time credential storage to a temporary directory; all CrewAI modules were imported normally. No live providers were called. The full repository suite was not run.Validated again on 2026-10-20 after rebasing onto upstream
mainat4f4573706ea4afee6c4da4c31cfb9622a4495ab7: 58 related tests passed; Ruff lint/format, strict mypy and whitespace checks passed. The final PR head is0062db8; the two changed source/test files are byte-for-byte identical to the previously reviewed head.Additional context
AI assistance: OpenAI Codex inspected the production callers and prior contributions, wrote the fix and behavioral tests, and ran the checks above. This PR is AI-generated and requires the
llm-generatedlabel.This change restores sequential context-manager behavior; it does not redesign process-wide logging concurrency.
Note
Low Risk
Narrow change to a logging helper used around ChromaDB calls; behavior is more correct on failure with regression tests and no auth or data-path impact.
Overview
Fixes
suppress_logging()so it always puts the target logger back to how it was configured, including when the wrapped block raises or is interrupted.The context manager now saves
logger.level(not the effective level) and restores it in afinallyblock, so a failed ChromaDB query no longer leaves the logger stuck atERROR, and loggers usingNOTSETkeep inheriting from the parent after suppression. Stdout/stderr redirection andUserWarningsuppression are unchanged.Adds
test_logger_utils.pywith parametrized tests for normal exit, errors,KeyboardInterrupt, andNOTSETinheritance after failures.Reviewed by Cursor Bugbot for commit e63764d. Bugbot is set up for automated code reviews on this repo. Configure here.