fix: apply redact() to remaining unredacted logger paths#2500
Merged
Conversation
FileLogger.log_chat_completion and log_new_agent, and SqliteLogger.log_chat_completion, log_event, and log_function_use were writing request data and event kwargs without passing them through redact(). API keys and other sensitive fields listed in SENSITIVE_KEYS could end up in log files or the SQLite database in plaintext. Wrap each of these call sites with _redact() (or _redact(to_dict(...)) where to_dict is already used), matching the pattern already applied to the other log methods by ag2ai#2485. Add 14 tests covering flat, nested, list-of-dicts, case-variant, non-dict, and empty-kwargs scenarios for both loggers.
Codecov Report✅ All modified and coverable lines are covered by tests.
... and 57 files with indirect coverage changes 🚀 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.
Why are these changes needed?
PR #2485 added
redact()toFileLogger.log_event,log_new_wrapper,log_new_client, andlog_function_use, but several other log methodswere missed:
FileLogger.log_chat_completion--to_dict(request)without_redact()FileLogger.log_new_agent--to_dict(init_args)without_redact()SqliteLogger.log_chat_completion--json.dumps(to_dict(request))without_redact()SqliteLogger.log_event--json.dumps(kwargs)without_redact()SqliteLogger.log_function_use--safe_serialize(args/returns)without_redact()API keys and other sensitive fields in
SENSITIVE_KEYScould be writtenin plaintext to log files or the SQLite database.
This PR wraps each call site with
_redact(), same pattern as #2485.Related issue number
Fixes missed paths from #2485.
Checks