Repository navigation
Scrub nested keys in GenAI content - #2823
Conversation
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
|
|
||
| # Message content can contain sensitive named fields alongside prose where | ||
| # matching the string value would produce false positives. | ||
| KEY_ONLY_KEYS = { |
There was a problem hiding this comment.
make the meanings of the three sets very clear, explain how they differ and why. should KEY_ONLY_KEYS be a subset of safe keys?
There was a problem hiding this comment.
(AI) Addressed in b7c3c54. KEY_ONLY_KEYS is now explicitly included in SAFE_KEYS, and comments define the three policies and their precedence.
There was a problem hiding this comment.
KEY_ONLY_KEYS is now explicitly included in SAFE_KEYS
but should it be? why or why not?
There was a problem hiding this comment.
(AI) Yes, with the current meaning of SAFE_KEYS. SpanScrubber exempts the outer attribute name, while KEY_ONLY_KEYS changes how its descendants are searched: nested keys match, string values do not. MessageValueCleaner also uses SAFE_KEYS to pass safe-named fields through scrub_value as a mapping; if a GenAI key were outside SAFE_KEYS and check_keys=False, it would pass the string directly and run value patterns on prose. The subset encodes that exemption. The name SAFE_KEYS is overloaded, but making the sets disjoint would require changing that caller too.
There was a problem hiding this comment.
All reported issues were addressed across 2 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
Summary
pydantic_ai.all_messages, including tool calls nested within those messages.This is PR 1 of the scrubbing-policy split. Provider scope handling and other Pydantic AI attributes remain separate.
Verification
uv run pytest -q -p no:cacheprovider tests/test_secret_scrubbing.py(82 passed)