Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Get started
Structured Logging With Redaction
00:00
5 left

Structured Logging With Redaction

HardPython

Problem

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:

  1. Its dictionary key matches one of the supplied sensitive keys, ignoring case. Replace the entire value, regardless of whether it is a string, number, list, or dictionary.
  2. A string contains an embedded Plaid access token matching 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.

Constraints

  • 1 <= number of dictionary and list elements <= 10^5
  • Nesting depth is at most 500
  • Dictionary keys are non-empty strings
  • Sensitive-key matching is exact after lowercasing
  • Do not mutate record

Function Signature

def redact_log_event(record, sensitive_keys):
Interviewer

Your question is Structured Logging With Redaction. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
Code
Sign up free to run your codeLog inLn 2
Run your code to see test output here.