Plaid services emit structured log events containing nested dictionaries and lists. Implement a sanitizer that returns a new event with sensitive financial values replaced by "[REDACTED]" before the event is written to logs.
A value must be redacted when either condition holds:
access-[A-Za-z0-9_-]+. Replace only the matching token, preserving the rest of the string.Recursively process dictionaries and lists. Preserve non-sensitive keys, list ordering, scalar values, and the original input object. Inputs are JSON-compatible values: dictionaries with string keys, lists, strings, numbers, booleans, or None.
def redact_log_event(record, sensitive_keys):