An Empty Collection and a Missing Resource
A successful collection query can contain no items. A missing individual record is a distinct outcome under a detail endpoint's contract.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Trace two URLs
A catalogue search can return a valid page with zero matching books. A request for an unknown book ID may return a not-found result. HTTP status families convey that difference at the response boundary.
Suggest the relevant action in each view
A collection might let readers clear restrictive filters. An absent record can link back to the catalogue. Missing, empty, and zero describes the same distinction in a smaller data model.[1][2]
Keep collection existence separate from matching results
GET on a valid catalogue with a filter can succeed and return zero items. GET on a specific item that does not exist can return 404 under the service contract. Empty results mean the query completed and selected none. See HTTP status codes.
/items?color=unrepresented → successful empty collection
/items/987 → missing-resource response when 987 is unknown
Both outcomes need clear browser or client handling
Distinguish unavailable data from a known empty set
A catalogue failing to query its storage cannot conclude zero items exist. Give dependency failures an explicit outcome and test an ordinary empty result, a missing item and a service error independently.