redash icon indicating copy to clipboard operation
redash copied to clipboard

API does not return status 404 for some missing resources

Open fjeldstad opened this issue 9 months ago • 0 comments

(This applies to the currently latest stable released Docker version of Redash.)

When integrating with the Redash API (or any API), it is crucial to be able to distinguish between errors where the caller did something wrong (400-range status codes) and application errors (500-range status codes). I've found the Redash API to be really inconsistent with regards to status codes for missing resources.

Some examples:

  • GET /api/data_sources/{id} → 404 🎉
  • POST /api/data_sources/{id} → 500 😕
  • GET /api/groups/{id} → 500 😕
  • POST /api/groups/{id} → 500 😕
  • GET /api/queries/{id} → 404 🎉
  • POST /api/queries/{id} → 404 🎉
  • GET /api/dashboards/{id} → 404 🎉
  • POST /api/dashboards/{id} → 500 😕

All 500 responses seem to have the body { "message": "Internal Server Error" } which is not helpful when trying to determine why the request failed.

In addition, any completely invalid url under /api/... (requested resource does not match any route, like /api/this/does/not/match/anything) results in a 200 response with HTML - also not optimal from a programmatic point of view.

Ideally, all missing API resources should result in a 404 response, regardless of HTTP verb.

fjeldstad avatar May 24 '24 13:05 fjeldstad