All jobs / Backend developer / API Development
Backend developer interview question · 0–1 years
The interviewer asks: “A handler throws. What does the client see?” Strongest answer?
The strongest answer
A stable error code and a safe message. Stack traces, SQL and host names stay in logs. 500 means we failed — not that we dump internals.
Why it works
Exactly. Clients get a contract (RFC 9457 Problem Details is the 2026 default). Operators get the stack in the log with a request id.
What a good answer covers
- Safe body + honest status.
- Stacks and SQL belong in logs.
- Don't launder errors into 200.
- Don't leak internals to clients.
Answers that fall short
- Close, but not the strongest: Return the exception message — it's useful for the frontend.
Exception messages include table names, constraint names and sometimes values. That's for logs, not for a mobile app. - Weak: Return 200 with { ok: false, error: "..." } for everything so fetch() never throws.
Hiding failure in 200 means retries, gateways and uptime checks all lie. Use 4xx/5xx and a body. - Red flag: Send the SQL, the database host and the stack to the client to speed up debugging.
Internals in the response is a recon gift. Debug with logs and traces, not with the attacker's browser.
Who gets asked this
More API Development questions
- The interviewer asks: “How do you paginate a list endpoint?” Strongest answer?
- The interviewer asks: “Where do you validate input?” Strongest answer?
- The interviewer asks: “PUT versus PATCH?” Strongest answer?
- The interviewer asks: “How should API errors look to clients?” Strongest answer?
- The interviewer asks: “How do you version a public JSON API?” Strongest answer?
- When would you pick gRPC over a JSON REST API, and what do you give up?
- Your OpenAPI document lists every path and method and nothing else. A partner team says integrating still…
- The interviewer asks: “You're building an internal platform API other teams will live on. What changes?”…