Repository navigation
fix: honor log fallback after correlation ID is cleared - #115
Open
Gaurang-goyal wants to merge 1 commit into
Open
Gaurang-goyal wants to merge 1 commit into
Gaurang-goyal wants to merge 1 commit into
Conversation
Use the configured default when the context explicitly contains None, as happens after worker cleanup. Preserve empty IDs and existing truncation behavior without changing the context. Add regression tests for cleared IDs, fallback truncation, empty strings, and string-format logging.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #115 +/- ##
==========================================
+ Coverage 94.44% 94.91% +0.47%
==========================================
Files 9 9
Lines 270 295 +25
==========================================
+ Hits 255 280 +25
Misses 15 15 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the correlation ID is explicitly cleared with
correlation_id.set(None),CorrelationIdFilter(default_value="-")currently attachesNoneto the log record.ContextVar.get(default)only uses its fallback when no value has been set, so the cleanup patterns documented for SAQ and Celery bypass the configured fallback. A formatter using{correlation_id:s}then raisesTypeError.Use the configured fallback when the retrieved ID is
None. Existing IDs, empty strings, truncation, and the defaultNonebehavior are preserved, and the context itself is not changed.Adds regression coverage for cleared IDs, fallback truncation, empty-string preservation, and formatting a cleared ID with a string format specifier.
Validation (Python 3.12/macOS):
Test dependencies were installed in an isolated environment using current versions. Two existing/dependency warnings concern the Starlette httpx test client and an asyncio marker on a synchronous test. Upstream multi-version CI has not run yet.