Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up error handling in all endpoints #125

Open
richardxia opened this issue Jul 14, 2024 · 1 comment
Open

Clean up error handling in all endpoints #125

richardxia opened this issue Jul 14, 2024 · 1 comment
Assignees

Comments

@richardxia
Copy link
Member

The error handling in the recently added Bookmarks, Folders, and Saved Search endpoints is fairly inconsistent. A few baseline things that we should do are:

  • Make sure that failures actually result in 4xx or 5xx status codes so that API clients are aware that an error occurred
  • Make sure client-side errors result in 4xx (usually 400) status codes
  • Make sure that server-side errors result in 5xx status codes
@rosschapman
Copy link

rosschapman commented Aug 29, 2024

Please also consider returning 2xxs with clear messaging in cases where data might be missing. For example, for client applications at Exygy, we've tried to access Service data that used to exist but was cached in an Algolia index. The response comes back with headers and no content, which is challenging to parse (in code, and semantically) because it could either suggest there is no data or the url destination is no longer available. For example, if we send a GET to retrieve service data at .../api/v2/services/4178 in a client application and receive the response below, how might we design an accurate error message for the user who's interested in that service?

This service has been discontinued, here are similar services...
There is a problem with our system, please try again...
etc...

HTTP/1.1 404 Not Found
X-Powered-By: Express
Content-Security-Policy: default-src 'none'
X-Content-Type-Options: nosniff
Content-Type: text/html; charset=utf-8
Content-Length: 150
Vary: Accept-Encoding
Date: Wed, 28 Aug 2024 23:51:18 GMT
Connection: keep-alive
Keep-Alive: timeout=5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

No branches or pull requests

3 participants