Page MenuHomePhabricator

Client Developer gets machine-readable results for failed routes
Closed, ResolvedPublic

Description

"As a Client Developer, I want to get 404 messages in a machine-readable form, so that my code can interpret them easily."

It seems like the routes in our gateway default to Portal if they don't match one of our API routes. That means that 404 errors will give the MediaWiki HTML page, instead of a machine readable JSON output.

The output should be similar to the Core REST API 404 output:

{
  "httpCode": 404,
  "httpReason": "Not Found"
}

Event Timeline

eprodromou removed eprodromou as the assignee of this task.Aug 19 2020, 5:32 PM

To clarify, I assume you mean URIs like https://api.wikimedia.org/blabla ?

And one more thing, I would assume we would want api.wikimedia.org with no path to redirect to the main page of the api portal?

Pchelolo claimed this task.Aug 20 2020, 6:34 PM
Pchelolo moved this task from Next Sprint to Doing on the Platform Team Workboards (Green) board.

I'll assume the answers to my questions above are yes and yes and implement it. We can clarify in code review.

To clarify, I assume you mean URIs like https://api.wikimedia.org/blabla ?

Correct. If there's not a route for it, we should give a JSON error.

And one more thing, I would assume we would want api.wikimedia.org with no path to redirect to the main page of the api portal?

Yes.

Change 621575 had a related patch set uploaded (by Ppchelko; owner: Ppchelko):
[operations/deployment-charts@master] api-gateway: JSON error responses and empty path redirect

https://gerrit.wikimedia.org/r/621575

Change 621575 merged by jenkins-bot:
[operations/deployment-charts@master] api-gateway: JSON error responses and empty path redirect

https://gerrit.wikimedia.org/r/621575

Pchelolo reassigned this task from Pchelolo to eprodromou.Aug 20 2020, 7:41 PM
eprodromou reassigned this task from eprodromou to Pchelolo.Aug 20 2020, 8:08 PM

Hmm. The httpReason is an empty string. Can we either leave it out entirely, or put "Not Found", like with the MW REST API?

Change 621620 had a related patch set uploaded (by Ppchelko; owner: Ppchelko):
[operations/deployment-charts@master] Provide a message for 404 response body

https://gerrit.wikimedia.org/r/621620

Change 621620 merged by jenkins-bot:
[operations/deployment-charts@master] Provide a message for 404 response body

https://gerrit.wikimedia.org/r/621620

Pchelolo added a subscriber: hnowlan.

no deploys on Friday :) @hnowlan feel free to deploy as well, should be really safe.

eprodromou closed this task as Resolved.Sep 22 2020, 5:21 PM