Background
Recently we realized that the way that the API is responding to routing errors has changed and it's quite different from the way that services do.
When we request something like:
https://wikimedia.org/api/rest_v1/metrics/**pageviews_invalid_route**/top/en.wikipedia/all-access/2022/01/02
we get the following error with content-type:application/json
{ "httpReason": "Not Found", "httpCode": 404 }
And when we make this request:
https://wikimedia.org/api/rest_v1/**metriasdasdcs**/pageviews/top/en.wikipedia/all-access/2022/01/02
we get the following one with content-type:application/json+problem
{ "type": "https://mediawiki.org/wiki/HyperSwitch/errors/not_found#route", "title": "Not found.", "method": "get", "uri": "/wikimedia.org/v1/metriasdasdcs/pageviews/top/en.wikipedia/all-access/2022/01/02" }
But services are responding errors like the following one with content-type:application/json+problem when we request something like https://wikimedia.org/api/rest_v1/metrics/pageviews/**wrong-endpoint**/en.wikipedia/all-access/2020/12
{ "detail": "Invalid route", "method": "get", "status": 404, "title": "Not Found", "type": "about:blank", "uri": "/metrics/pageviews/wrong-endpoint/en.wikipedia/all-access/2020/12" }
So, at this moment, we have three different responses for three similar wrong request regarding the provided route.
According to what we know at this moment:
- /api/rest_v1/metrics/ will hit the gateway
- /api/rest_v1/blahlahalvb will hit restbase
- any other case with a valid /api/rest_v1/metrics/right_basepath/ will hit an specific service
Goal
The goal here would be to align the response for all these errors. We should have the same response structure and content-type regardless which part (gateway, restbase or a service) is responding.
The right response structure should be the one we are using for services (the last one shown above).
Acceptance criteria
- Same structure is used for all routing error cases
- Same content-type (application/json+problem) is used for all routing error cases