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
21 practiced
Explain the differences between logs, metrics, and traces for ML observability. For production error handling, which signals would you rely on for alerting vs for debugging, and how would you correlate them to investigate an inference-time failure?
EasyTechnical
24 practiced
Input coming from external systems can include malicious or malformed values. For ML systems that accept feature payloads or serialized artifacts, describe security-oriented input checks you would put in place to defend against injection, deserialization attacks (e.g., pickles), and excessively large payloads.
MediumTechnical
26 practiced
Explain concrete runtime strategies to avoid GPU memory exhaustion during large-model inference or training. Cover: batching size adaptation, gradient accumulation (for training), model sharding, mixed precision, monitoring/gauging memory, and safe failure handling when memory is insufficient.
MediumTechnical
27 practiced
You have an external inference service that sometimes fails transiently. Design a retry and idempotency strategy for an ML client that must avoid duplicate downstream side-effects (e.g., billing events). Describe how to generate idempotency keys, where to store them, TTL considerations, and how to handle concurrent retries from multiple clients.
EasyTechnical
21 practiced
Numeric features sometimes contain extreme values or out-of-range inputs that can cause overflow or unstable behavior in models (e.g., exp overflow). Describe defensive protections you would implement when preprocessing numeric features and in model code to avoid overflow, underflow, or catastrophic activation values.

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.