InterviewStack.io LogoInterviewStack.io

Error Handling and Code Quality Questions

Focuses on writing production quality code and scripts that are defensive, maintainable, and fail gracefully. Covers anticipating and handling failures such as exceptions, missing files, network errors, and process exit codes; using language specific constructs for error control for example try except blocks in Python or set minus e patterns in shell scripts; validating inputs; producing clear error messages and logs; and avoiding common pitfalls that lead to silent failures. Also includes code quality best practices such as readable naming and code structure, using standard libraries instead of reinventing functionality, writing testable code and unit tests, and designing for maintainability and observability.

MediumTechnical
94 practiced
Refactor the following Python function into testable components. Original function reads a config file, makes an HTTP call to an external service, parses the JSON response, and writes results to disk. Describe how to separate I/O from logic, apply dependency injection, and present a refactored sketch with clear interfaces so each part can be unit tested with mocks.
MediumTechnical
75 practiced
You're receiving millions of repetitive error logs from a noisy downstream integration which drowns out real alerts. Propose concrete strategies to reduce noise without losing critical signals: per-error-key sampling, rate-limiting log emission, dynamic log-level configuration, and metrics-derived alerts. Explain implementation trade-offs and how to preserve at least a sample of full stacktraces for debugging.
EasyTechnical
93 practiced
You observe ephemeral subprocesses and file descriptors leaking when jobs fail. As an SRE, describe code patterns to avoid resource leaks in scripts and services. Provide concrete examples: use of Python context managers, finally blocks, proper subprocess termination, process groups, and closing sockets. Show how to ensure cleanup runs even under KeyboardInterrupt or fatal error scenarios.
EasyTechnical
103 practiced
Explain the role of linters and static analyzers in SRE-maintained codebases. Which checks are especially valuable for preventing reliability issues (for example unhandled return values, unchecked errors, missing resource closures, and missing type annotations)? How would you configure linters in CI to block unsafe changes while avoiding noise that causes developers to bypass checks?
MediumTechnical
87 practiced
A third-party API intermittently fails and your pipeline silently drops data. Outline concrete changes to harden the ingestion pipeline: reliable queuing, retries with backoff, dead-letter queue for problematic events, idempotent writes, alerting on sink failure, and monitoring that detects drops. Provide a brief architecture description and mention code-level patterns for safe retries.

Unlock Full Question Bank

Get access to hundreds of Error Handling and Code Quality interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.