All problems

Batch Lookup API Returns Results in the Wrong Order

Level 2 · node · API · Batch response does not preserve request order

Scenario

A fictional library kiosk submits an array of book IDs to retrieve their loan statuses in one request. The repository sorts matches by title, but the API contract requires results to follow the order of requested IDs. The current implementation forwards the repository output directly, associating loan statuses with incorrect books on the kiosk.

Requirements

Return one result for each requested book ID in the exact request order. Unknown IDs must produce a placeholder with status='missing' at their original position. Repeated IDs must produce repeated results, and an empty request must return an empty array.

Acceptance criteria

  • Results follow requested IDs even when repository sorting differs.
  • An unknown ID is marked missing at its requested position.
  • Repeated IDs appear as many times as requested.
  • An empty request returns an empty array.