Page MenuHomePhabricator

Dont propagate server error details to end users
Closed, ResolvedPublic

Description

With RESTBase handling all the requests between edge and the backend we didn't handle our error responses in a special way.
Instead RESTBase was hiding the error and threw a 404. Throwing a 404 can be confusing but not sharing backend implementation details to the end user is a good practice.
In the new architecture with rest gateway it might be a good idea to throw a 500 error but hide the details from the clients.

For example, from a known failing request:

jgiannelos@deploy2002:~$ curl https://mobileapps.svc.codfw.wmnet:4102/crh.wikipedia.org/v1/page/summary/Rusiye
{"status":500,"type":"internal_error","detail":"<!DOCTYPE html>\n<html lang=\"en\" dir=\"ltr\">\n<meta charset=\"utf-8\">\n<title>Wikimedia Error</title>\n<!-- reqId 1cd37dab-46a9-45ba-95a4-836bf075adcd -->\n<style>\n* { margin: 0; padding: 0; }\nbody { background: #fff; font: 15px/1.6 sans-serif; color: #333; }\n.content { margin: 7% auto 0; padding: 2em 1em 1em; max-width: 640px; }\n.footer { clear: both; margin-top: 14%; border-top: 1px solid #e5e5e5; background: #f9f9f9; padding: 2em 0; font-size: 0.8em; text-align: center; }\nimg { float: left; margin: 0 2em 2em 0; }\na img { border: 0; }\nh1 { margin-top: 1em; font-size: 1.2em; }\np { margin: 0.7em 0 1em 0; }\na { color: #0645ad; text-decoration: none; }\na:hover { text-decoration: underline; }\ncode { font-family: inherit; }\n.text-muted { color: #777; }\n@media (prefers-color-scheme: dark) {\n  a { color: #9e9eff; }\n  body { background: transparent; color: #ddd; }\n  .footer { border-top: 1px solid #444; background: #060606; }\n  #logo { filter: invert(1) hue-rotate(180deg); }\n  .text-muted { color: #888; }\n}\n</style>\n<meta name=\"color-scheme\" content=\"light dark\">\n<div class=\"content\" role=\"main\">\n<a href=\"https://www.wikimedia.org\"><img id=\"logo\" src=\"https://www.wikimedia.org/static/images/wmf.png\" srcset=\"https://www.wikimedia.org/static/images/wmf-2x.png 2x\" alt=Wikimedia width=135 height=135></a>\n<h1>Error</h1>\n<p>Our servers are currently under maintenance or experiencing a technical problem. Please <a href=\"\" title=\"Reload this page\" onclick=\"location.reload(false); return false\">try again</a> in a few&nbsp;minutes.</p><p>See the error message at the bottom of this page for more&nbsp;information.</p>\n</div>\n<div class=\"footer\">\n<p>If you report this error to the Wikimedia System Administrators, please include the details below.</p>\n<p class=\"text-muted\"><code>\n  Request ID: 1cd37dab-46a9-45ba-95a4-836bf075adcd<br/>\n  Allowed memory size of 1468006400 bytes exhausted (tried to allocate 3859360 bytes)</code></p></div>\n</html>\n","method":"GET","uri":"/crh.wikipedia.org/v1/page/summary/Rusiye"}

The client should receive something like:

< HTTP/1.1 500 Internal Server Error
Something went wrong

with the status code returned from the backend.

Event Timeline

Change #1118077 had a related patch set uploaded (by Jgiannelos; author: Jgiannelos):

[mediawiki/services/mobileapps@master] Hide error details on upstream prod responses

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

@hnowlan In case we don't want to implement that logic on rest-gateway I sent a patch to hide details when NODE_ENV == production. In that case we need to disable that on staging so we can debug things easily.

Change #1118077 merged by jenkins-bot:

[mediawiki/services/mobileapps@master] Hide error details on upstream prod responses

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