InterviewStack.io LogoInterviewStack.io

Error Handling and Defensive Programming Questions

Covers designing and implementing defensive, fault tolerant code and system behaviors to prevent and mitigate production failures. Topics include input validation and sanitization, null and missing data handling, overflow and boundary protections, exception handling and propagation patterns, clear error reporting and structured logging for observability, graceful degradation and fallback strategies, retry and backoff policies and idempotency for safe retries. Also address concurrency and synchronization concerns, resource and memory management to avoid exhaustion, security related input checks, and how to document and escalate residual risks. Candidates should discuss pragmatic trade offs between robustness and complexity, show concrete defensive checks and assertions, and describe test strategies for error paths including unit tests and integration tests and how monitoring and operational responses tie into robustness.

HardTechnical
0 practiced
You're investigating a production outage where clients retried rapidly and downstream databases were overloaded, causing cascading failures. Outline a post-incident action plan: root-cause analysis steps, immediate mitigations (throttling, disable retries), medium-term fixes, monitoring improvements, and policy changes to prevent recurrence.
HardTechnical
0 practiced
Describe a systematic approach to attribute an increase in end-to-end latency to a specific microservice using distributed traces, sampling, dependency graphs, and metrics. Explain how to combine traces with logs and metrics to build evidence of causation rather than mere correlation.
MediumTechnical
0 practiced
Given a REST endpoint that accepts user-provided HTML for a profile bio, design a sanitization policy that prevents XSS while preserving basic formatting (bold, links). Recommend libraries or algorithms, discuss server-side vs client-side sanitization, and outline tests you would write to ensure correctness and avoid regressions.
EasyTechnical
0 practiced
Compare exception-based error handling and error-value/Result-pattern handling in backend services (e.g., exceptions in Java/Python vs Result objects in Rust/Go-style errors). Discuss readability, propagation, performance, and how libraries exposed by SRE teams should surface errors for operational debugging.
MediumTechnical
0 practiced
Design and provide pseudocode for an idempotent POST endpoint for a payments service that accepts an 'Idempotency-Key' header. Requirements: ensure at-most-once effect or consistent responses on retries, handle concurrent requests with the same key, expire keys after 24 hours, and store enough response metadata to replay identical responses. Describe storage and locking choices.

Unlock Full Question Bank

Get access to hundreds of Error Handling and Defensive Programming interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.