Design input validation and error handling
Company: Meta
Role: Software Engineer
Category: System Design
Difficulty: hard
Interview Round: Technical Screen
Design the API and system-level input validation and error-handling strategy for a service that computes the top-k most frequent elements in an input array. Specify the request/response schema, limits (payload size, k bounds, element domains), idempotency, authentication, rate limits, timeouts, and error taxonomy (client vs. server errors). Describe validation layers (client, gateway, service), schema enforcement, partial-failure behavior, observability (metrics, logs, traces), and safeguards for malformed/poisoned payloads. Explain how you would test and monitor this in production.
Quick Answer: This question evaluates a candidate's competency in designing APIs, input validation, structured error handling, operational guardrails, observability, security controls, and testing for a Top-K frequency service.