Which errors should an API workflow catch, retry or report?
Understand the idea, explain it in your own words and use the rubric to find your next learning gap.
The idea behind the question
Error categories have different recovery policies. A validation failure, authorization failure, provider limit and network timeout should not collapse into the same generic success response.
An extraction worker receives malformed local data, then a provider timeout while processing a different valid record.
def read_name(record):
try:
return record["name"]
except KeyError:
return "Missing name"
print(read_name({"name": "Subo"}))
print(read_name({}))
try:
read_name(None)
except TypeError:
print("Wrong input type remains visible")Show expected output
Subo
Missing name
Wrong input type remains visibleCopy and paste to run in a separate tab. This example illustrates one concept; it is not a complete application or an automatically graded task.
A practical way to learn it
Run the missing-field example. Add separate handling for a malformed record and an unavailable provider without pretending either succeeded.
Open Python playgroundThe related tool opens separately; your interview answer stays here. Written practice is self-guided, without automatic code grading.
Build an explanation you understand
- State what the concept does in plain language.
- Apply it to the example and make your assumptions explicit.
- Explain a trade-off, failure case and how you would test it.
- Distinguish your actual experience from a proposed approach.
How would you explain it?
Single-question timers reset on refresh. Full mock sessions can resume from this browser.
Strengthen your explanation
Compare reasoning, not identical wording. Reference answers describe a possible approach; replace hypothetical statements with truthful details from your own work.
One way to answer
I would classify failures at clear boundaries and catch the specific exceptions I can handle. Invalid input usually needs correction, not repeated network calls. A transient dependency failure may qualify for a bounded retry, while an authorization failure requires configuration or permission changes. I would preserve useful exception context internally and return a safe, actionable error to the caller. Cleanup belongs in a context manager or finally block. I would not catch every exception and return an empty answer, because that makes failed work look like a valid result and damages evaluation.
What a strong explanation should cover
Tick only the points your own answer addresses. This is self-assessment, not AI scoring.
0 / 3 points self-reportedWatch out for
- Catching Exception and silently returning an empty dictionary.
Now go one level deeper
- What should a batch do when only one record is invalid?
- Which error details must stay out of a public response?
Further reading
Further-reading links support learning; the reference is Sukoaa-authored, not an official employer answer key.