logger: dedupe equal RedactionFilters on register_callback#330
Merged
Conversation
RedactionFilter gains value equality (__eq__/__hash__ on keys, pattern sources, redact_with) and CommonLogger.register_callback skips a callback that already compares equal. Registering the same filter from multiple handler entrypoints in one process is now idempotent (no stacked passes). Distinct callbacks still stack.
|
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.



What
RedactionFiltergains value equality:__eq__/__hash__over itskeys, pattern sources, andredact_with.CommonLogger.register_callbackskips a callback that already compares equal (dedup).Why
Each handler entrypoint calls
LogFilter.register()at import. A process that loads more than one entrypoint (test suites, multi-handler processes) previously stacked N identicalRedactionFilters and scrubbed every record N times. Now it's idempotent — register the same filter as many times as you like, it lands once. Genuinely different callbacks still stack.Fixes the duplicate-registration footgun at the framework level (vs a per-repo guard in every consumer's bootstrap).
Validation
pytest tests/acai_aws: 615 passed (5 new: filter equality/inequality + register dedup).pylint acai_aws --recursive=y --fail-under 10: 10.00/10.Backward compatible. Warrants a patch release (2.8.1).