KatInterview

Fixing Three Hidden Bugs in an Unfamiliar Vehicle-Booking API

System DesignModel answer
MediumModel answerSystem Designdebuggingnodejsaccess-control

Last updated

Debug an unfamiliar Node.js vehicle-booking backend where one user's list exposes others' vehicles, new vehicles are missing, and edits revert after refresh.

You are handed a Node.js backend for a vehicle-booking app that you have never seen before. It ships with API documentation and a preset test suite, and several tests currently fail. You have limited time.

Three unrelated defects have been reported:

  1. Foreign vehicles in "My Cars". The endpoint meant to list only the signed-in user's vehicles also returns vehicles owned by other users.
  2. Added vehicle is invisible. After a user creates a vehicle, it does not show up in their list.
  3. Edits revert. An edit request seems to succeed, but after a page refresh the vehicle shows its old values.

The goal is to make every preset test pass without introducing regressions.

The code is not provided, so describe your approach:

  • In what order do you explore the project and the failing tests?
  • For each symptom, which code paths do you inspect and what are the most probable root causes?
  • What does each fix look like?
  • How do you verify each fix and make sure nothing else breaks?

Assume a conventional layout (routes, authentication middleware, handlers or services, a data store) and state any assumptions you make. Listing the clarifying questions you would ask is welcome, for example how the user is identified, what the data store is, whether a cache exists, and whether tests hit HTTP or service functions.

Cover all three bugs. For bug 1, also address whether the problem is purely cosmetic or something more serious.

Hints

Hint 1

Run the test suite before reading any code, and map each failing test to one of the three symptoms. Then read each endpoint against what the API documentation says it should do.

Hint 2

For the missing vehicle, decide first whether the write failed or the read failed: inspect the stored data directly after a create. Then check which fields the list filter depends on and whether a cache is serving stale data.

Hint 3

For lost edits, look at how the update finds its record and what it does when nothing matches. Check whether the modified object is actually saved back and whether the response reflects stored state or just echoes the request.