Debug Watch List Movie Operations
You are tasked with debugging and fixing backend logic for a full-stack Movie DB application. The application allows users to log in, create, update, and delete watch lists, and add or remove movies from these lists. Several unit tests are failing specifically around watch-list movie operations. Your primary goal is to correct the handler logic to ensure the following scenarios function correctly, with proper persistence and HTTP responses.
Scenarios to Address:
- Add a movie to an existing watch list.
- Add a movie that is already present in the watch list.
- Remove a movie from an existing watch list.
- Add many movies to a watch list, then remove them one by one.
- Attempt to add a movie to a watch list that does not exist.
- Attempt to remove a movie from a watch list that does not exist.
Constraints & Assumptions:
- REST Contract: Assume a conventional REST contract:
POST /watchlists/{watchListId}/moviesadds a movie (movie identifier from request body).DELETE /watchlists/{watchListId}/movies/{movieId}removes a movie.404 Not Foundfor non-existent watch list or movie.409 Conflictfor attempting to add a duplicate movie.201 Createdor200 OKfor successful add.200 OKor204 No Contentfor successful delete.
- Identifier Types: Watch lists store movie identifiers, which may be object/reference types, not just strings.
- Asynchronous Persistence: The persistence layer is asynchronous; handlers must wait for saves to complete before responding.
- API Convention: Adhere to existing API conventions for status codes where choices exist (e.g.,
201vs200).
Note: This is a debugging exercise. Focus on correcting handler logic, not redesigning the system. The data model and routing are pre-existing.
AI interview prep
Core dilemma
Ensuring data integrity and correct state transitions in an asynchronous, potentially concurrent environment, while adhering to a strict API contract for CRUD operations on a collection.
3 tradeoffs and 3 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Debug Watch List Movie Operations
You are tasked with debugging and fixing backend logic for a full-stack Movie DB application. The application allows users to log in, create, update, and delete watch lists, and add or remove movies from these lists. Several unit tests are failing specifically around watch-list movie operations. Your primary goal is to correct the handler logic to ensure the following scenarios function correctly, with proper persistence and HTTP responses.
Scenarios to Address:
- Add a movie to an existing watch list.
- Add a movie that is already present in the watch list.
- Remove a movie from an existing watch list.
- Add many movies to a watch list, then remove them one by one.
- Attempt to add a movie to a watch list that does not exist.
- Attempt to remove a movie from a watch list that does not exist.
Constraints & Assumptions:
- REST Contract: Assume a conventional REST contract:
POST /watchlists/{watchListId}/moviesadds a movie (movie identifier from request body).DELETE /watchlists/{watchListId}/movies/{movieId}removes a movie.404 Not Foundfor non-existent watch list or movie.409 Conflictfor attempting to add a duplicate movie.201 Createdor200 OKfor successful add.200 OKor204 No Contentfor successful delete.
- Identifier Types: Watch lists store movie identifiers, which may be object/reference types, not just strings.
- Asynchronous Persistence: The persistence layer is asynchronous; handlers must wait for saves to complete before responding.
- API Convention: Adhere to existing API conventions for status codes where choices exist (e.g.,
201vs200).
Note: This is a debugging exercise. Focus on correcting handler logic, not redesigning the system. The data model and routing are pre-existing.