arenanet / api-cdi

Collaborative Development Initiative for Public APIs
257 stars 41 forks source link

Invalid render url doen't return correct error message #383

Closed Ruhrpottpatriot closed 8 years ago

Ruhrpottpatriot commented 8 years ago

If you try to access the wrong URL on the render endpoint you'll receive a crypric error page in HTML, instead of the usual JSON error message. Parsing this case introduces needless conditional statements and thus introduces complexity to the application.

Steps to reproduce:

<html>
<body><p>Page not found</p>
<dl>
<dt>Host</dt><dd>render-live.ncplatform.net</dd>
<dt>URL</dt><dd>/colors</dd>
<dt>Remote Address</dt><dd>54.182.239.51:13227</dd>
</dl>
<p>RenderSrv/101.67732 Instance/694.497485386</p>
</body>
</html>

Judging from the X-Cache and the Via header (which return "Error from cloudfront" and 1.1 2db316290386960b489a2a16c0a63643.cloudfront.net (CloudFront) respectively), this seems to be a redirection error from CloudFront.

From my testing this seems to happen with every invalid render url and should be fixed.

Archomeda commented 8 years ago

While I agree that error pages should be consistent with something, I'm not sure if it should return JSON. I haven't seen any JSON message at all so far on this domain. The entire domain render.guildwars2.com is used for providing images that are linked from certain items, etc. from api.guildwars2.com.

Also, never request pages without checking the response header for the HTTP status code. Even the api.guildwars2.com domain can spit out HTML pages that they can't fix due to how IIS works. You get a 404 response (or any other error) that you can always catch this way.

tivac commented 8 years ago

It's not a Cloudfront error, fwiw. Cloudfront uses our servers as origins for the CDN and is correctly passing back the RenderSrv 404 page.

RenderSrv is returning a 404 status code, which is correct.

render.guildwars2.com usually only outputs raw images, so I disagree on an expectation of the 404 message being JSON. That page is the standard 404 response from our server stack and overriding that behavior in this one case would be technical debt of debatable value.