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
0 practiced
Implement a robust CSV reader in Python that validates headers, handles UTF-8 BOM, inconsistent quoting, maximum line length to prevent DoS, reports informative errors including row numbers and error reasons, and streams large files to avoid OOM. Describe trade-offs between strict mode (fail early) and best-effort mode (skip bad rows) and provide a code sketch using the csv module.
MediumTechnical
0 practiced
Design a set of observability metrics to monitor error handling in a model-serving system. Identify useful counters, gauges, and histograms (e.g., error_rate_total, retry_count, prediction_latency_ms_bucket, schema_mismatch_total, model_version_errors) and propose labels to attach (endpoint, model_version, region) while avoiding high-cardinality labels. Explain how you'd use these metrics for alerting and debugging.
EasyTechnical
0 practiced
As an AI engineer maintaining a shared Python library, explain the benefits and trade-offs of adding static type annotations (PEP 484) and running mypy. Show a small annotated example: a Model class __init__ and an inference function. Discuss how to handle third-party libraries without type stubs, and how type checking fits into CI and refactors.
HardTechnical
0 practiced
You're seeing subtle, reproducible differences in model outputs after scaling distributed training from 2 to 8 nodes. Outline a detailed debugging approach to find the root cause: creating a deterministic reproducer, logging checksums of intermediate activations, comparing outputs layer-by-layer, examining floating-point nondeterminism, differing library/build versions, and validating data sharding. Provide a prioritized step-by-step plan.
MediumTechnical
0 practiced
Write a Python decorator `warn_if_slow(threshold_ms)` that times a function execution, logs a warning if it exceeds the threshold (including function name and duration), preserves the wrapped function's metadata using functools.wraps, and emits a metric counter. Provide code and explain how you'd avoid high overhead for functions called in tight loops.

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.