Conversation
…trings
init_structlog() was wrapping every positional argument with repr():
args=tuple(repr(a) for a in details.args)
This turned the original Python objects into opaque strings before
structlog processors ever saw them, breaking use-cases like:
- Censoring/redacting sensitive values (a processor receives
"'secret'" instead of the object it knows how to detect)
- JSON serialization (repr strings aren't valid JSON primitives)
- Log filtering based on argument type or value
kwargs already passed through as-is (dict(details.kwargs.items())),
so args gets the same treatment now.
Fixes hynek#151
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.
Fixes #151.
Problem
init_structlog()was wrapping every positional argument withrepr()before passing it to structlog:This converted the original Python objects into opaque strings before any structlog processor ever saw them. Processors that need the real values — censoring/redacting sensitive fields, JSON serialization, filtering by type — received
"'secret'"(a string) instead of the actual object.kwargswas already passed through as-is, so this alignsargswith the same treatment.Fix
Test
Added
test_args_logged_as_original_objectswhich passes a sentinel object as both a positional and keyword argument, then asserts that the log entry contains the exact same object (by identity), not a repr string.