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.

MediumTechnical
0 practiced
Discuss when to use assertions versus raising explicit exceptions and when to gate validation behind runtime feature flags. Provide examples from production ML code showing the performance, safety, and developer-debugging trade-offs of each choice.
HardSystem Design
0 practiced
Design a GPU cluster scheduler that defends against resource exhaustion from misbehaving jobs. Include per-user and per-team quotas, preemption policies, OOM detection and automated mitigation, container/cgroup isolation, graceful eviction with checkpointing, and fairness policies. Explain how to balance throughput, fairness, and responsiveness for interactive jobs.
EasyTechnical
0 practiced
Explain idempotency in the context of APIs that schedule model training jobs or record predictions. Provide simple examples of idempotency tokens and deduplication strategies, and explain when idempotency is required (e.g., safe retries) versus when it is optional.
MediumTechnical
0 practiced
Write Python client code for send_with_retries(session, url, payload, idempotency_key=None, total_timeout=60) that retries HTTP POSTs using exponential backoff with jitter, sets an Idempotency-Key header when provided, and respects a total timeout. Include a local in-memory deduplication cache keyed by idempotency_key to avoid duplicate sends within a short window.
HardTechnical
0 practiced
Design a structured error-reporting schema and logging plan for an ML platform that maps errors to SLOs, runbooks, and escalation stages. Specify error codes and severity levels, required diagnostic metadata, who to page for each severity, and the incident lifecycle from alert to postmortem and remediation tracking.

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.