Archived 2022.11.20. Content moved to error scenarios and responses.
Question
What return code should be specified in the case of an incorrect 'page' parameter?
For example:
Given an Data Holder (DH) has 25 total records which would match a certain request, in that request the Accredited Data Recipient (ADR) specifies:
- page-size of 10 AND page=5
As the request is outside the total number of records available, some form of error should be returned, as page 5 does not exist in this case. Should the DH return:
- A
200
with no data? - Page 1 by default?
- A
400
-range error? (and which one in particular) - Finally, where is this specified in the Consumer Data Standards?
Answer
The Consumer Data Standards around the treatment of the pagination parameters are in the pagination section: CDS pagination.
This section does not explicitly define the error response if an unavailable page is requested. As no specific behaviour is defined, the interpretation is left to the Data Holder. The following would both be considered valid responses based on the standards:
- A response of
200
with no records and meta data populated as per normal - A response of
400
, recognising that an invalid page setting could be considered a malformed request - A response of
422
based on the interpretation of an invalid page number being valid according to the schema, but invalid based on business logic. In this case an error payload must be supplied.
Comments
2 comments
Enhanced Error handling introduces an "Invalid Page" error response so the following statement now seems invalidated:
"As no specific behaviour is defined, the interpretation is left to the Data Holder. The following would both be considered valid responses based on the standards:"
Oddly, Enhanced Error Handling was released 1 June 2021 and this article was created in October 2021.
Is this errata now invalid?
Apologies October 2020, edited in July 2021.
Please sign in to leave a comment.