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
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.
HardTechnical
0 practiced
As an AI engineering lead, draft the skeleton of a policy to document residual risks after defensive measures are applied. The policy should state how to record residual risks, acceptance criteria, monitoring requirements, who must approve accepted risks, and the escalation path to security, legal, and senior leadership. Include timelines and review cadence.
MediumTechnical
0 practiced
Provide a concrete sanitization pipeline for textual prompts to a generative model. Include steps or pseudocode for language/encoding checks, length limits, instruction-stripping heuristics, allowed-token filters, rate limiting, logging and sampling of blocked prompts, and safe-mode toggles. Discuss false-positive risks and how to tune for recall vs precision.
EasyTechnical
0 practiced
You're building a REST endpoint that receives a JSON payload with a feature vector to run model inference. List and explain the essential input validation and sanitization steps you would implement server-side before invoking the model. Cover syntactic checks (types, required keys), semantic checks (value ranges, shapes), and security-oriented sanitization for malicious payloads or excessively large inputs.
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.

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.