Skip to content

logger: dedupe equal RedactionFilters on register_callback#330

Merged
paulcruse3 merged 1 commit into
masterfrom
sweet-12-redaction-dedup
Jun 17, 2026
Merged

logger: dedupe equal RedactionFilters on register_callback#330
paulcruse3 merged 1 commit into
masterfrom
sweet-12-redaction-dedup

Conversation

@paulcruse3

Copy link
Copy Markdown
Member

What

  • RedactionFilter gains value equality: __eq__ / __hash__ over its keys, pattern sources, and redact_with.
  • CommonLogger.register_callback skips 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 identical RedactionFilters 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).

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.
@sonarqubecloud

Copy link
Copy Markdown

@paulcruse3 paulcruse3 merged commit 89ae910 into master Jun 17, 2026
9 checks passed
@paulcruse3 paulcruse3 deleted the sweet-12-redaction-dedup branch June 17, 2026 06:37
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.

1 participant