~sbinet/sako#32: 
skapi: GET /api/entries endpoint should return 404 when no entries returned

When no items are available for the selected filters, the Wallabag API returns a 404 status code with the following body:

{
    "type": "https://tools.ietf.org/html/rfc2616#section-10",
    "title": "An error occurred",
    "status": 404,
    "detail": "Not Found"
}

The Sako implementation returns a 200 status code with the following body:

{
    "page": 3,
    "limit": 5,
    "pages": 2,
    "total": 9,
    "_links": {
        "self": {
            "href": "/api/entries?detail=metadata&order=desc&page=3&perPage=5&sort=created"
        },
        "first": {
            "href": "/api/entries?detail=metadata&order=desc&page=1&perPage=5&sort=created"
        },
        "last": {
            "href": "/api/entries?detail=metadata&order=desc&page=2&perPage=5&sort=created"
        },
        "next": {
            "href": "/api/entries?detail=metadata&order=desc&page=2&perPage=5&sort=created"
        }
    },
    "_embedded": {
        "items": null
    }
}

Some applications, like the Koreader Wallabag plugin, expect a 404 status response in this situation and crash when the items are null.

https://github.com/koreader/koreader/blob/06696ea913b5ca7ad8fb0641bbc5c809d28c54ce/plugins/wallabag.koplugin/main.lua#L513

While the API could be better designed, it would be useful to keep the Sako API as close as possible to Wallabag's behavior. What do you think?

Thank you for your work!

Status
REPORTED
Submitter
~ruben
Assigned to
No-one
Submitted
a month ago
Updated
a month ago
Labels
No labels applied.

~sbinet a month ago

Hi ~ruben,

Thanks for the report (and the patches). I'll have a look at those shortly (by the end of the week).

Apologies for the belated answer.

-s

Register here or Log in to comment, or comment via email.