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.

HardTechnical
0 practiced
Write a pytest unit test for a function process_batch(batch, sender) in Python that sends each item using sender.send(item). The function must retry transient failures up to 3 times per item and must not duplicate successfully sent items. Using mocking, simulate flaky sender behavior where some calls fail once and then succeed. Show assertions that verify correct retry behavior and no duplicate sends for successes.
EasyTechnical
0 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?
EasyTechnical
0 practiced
Explain best practices for error propagation across service boundaries. When should a service wrap an error with additional context versus propagating the original error? How should errors be modeled for observability and retries (error codes, canonical error types, and retention of causal stack information)? Give concrete patterns in Python or Go for preserving context while enabling programmatic checks.
MediumTechnical
0 practiced
Tail latency has increased because of downstream timeouts. Explain how you would implement timeouts at multiple layers to protect the system: client SDK timeouts, HTTP client timeouts, worker thread pool task deadlines, and request-level deadlines propagated via context or headers. Include code examples or pseudocode showing how to enforce a global deadline and cancel subtasks when it expires.
MediumTechnical
0 practiced
Write a robust Bash deployment script that performs a blue-green switch on Nginx upstreams. Requirements: use set -euo pipefail, validate input parameters, backup current configuration to a timestamped file, test the new config with nginx -t before switching, reload Nginx atomically, and rollback to the backup on failure. Include a trap to clean temporary files on exit.

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.