Why is a successful HTTP connection not necessarily a successful model request?
Understand the idea, explain it in your own words and use the rubric to find your next learning gap.
The idea behind the question
Transport completion, HTTP success, valid JSON and a valid business result are separate checks. Error handling should preserve this distinction at every API boundary.
A provider sends HTTP 200 with an incomplete response, or an error response contains HTML instead of the JSON your client expected.
# Synthetic statuses: no network requests are made.
def classify(status):
if 200 <= status < 300:
return "check payload"
if status == 429:
return "consider bounded retry"
if status in (401, 403):
return "check access; do not blindly retry"
return "handle explicit failure"
for status in [200, 403, 429, 500]:
print(status, classify(status))Show expected output
200 check payload
403 check access; do not blindly retry
429 consider bounded retry
500 handle explicit failureCopy 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 offline response-classification example. Add a case where HTTP 200 has an invalid payload and describe the expected API error.
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 check the HTTP status, then parse the response defensively and validate the expected result shape. I would handle empty, blocked or truncated model outputs as explicit non-success states even if the connection worked. I would distinguish authentication problems, validation errors and rate limits from transient outages. The user should get a clear next action without raw credentials or provider internals. I would test non-JSON and oversized responses, not just the happy path. Network success alone must never make a failed extraction look like an accurate empty answer.
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
- Calling response.json() on every response without considering its status or content.
Now go one level deeper
- How would you handle HTTP 204?
- When should a 429 response be retried?
Further reading
Further-reading links support learning; the reference is Sukoaa-authored, not an official employer answer key.