Return 404s intead of 500s for invalid cluster ids for many endpoints
dmitrizagidulin opened this issue · 3 comments
dmitrizagidulin commented
Not urgent, but let's clean up some of these 500 errors when passing an invalid cluster id (and return 404 Not Found / {"error": "Invalid cluster id, or cluster is unavailable."}
instead).
- List nodes -
curl localhost:9000/explore/clusters/invalid/nodes
returns 500 - List bucket types -
curl localhost:9000/explore/clusters/invalid/bucket_types
returns 500 - Get bucket type props, invalid cluster -
curl localhost:9000/explore/clusters/invalid/bucket_types/default
returns 500 - Get bucket type jobs, invalid cluster -
curl localhost:9000/explore/clusters/invalid/bucket_types/default/jobs
returns 500 - Get bucket type's buckets, invalid cluster -
curl localhost:9000/explore/clusters/invalid/bucket_types/default/buckets
returns 500 - Get a bucket's jobs -
localhost:9000/explore/clusters/invalid/bucket_types/default/buckets/$bucket/jobs
- returns 500 - Get a bucket's key cache -
localhost:9000/explore/clusters/invalid/bucket_types/default/buckets/$bucket/keys
returns 500 - All the Riak proxy endpoints -
localhost:9000/riak/clusters/invalid/...
return 500.
dmitrizagidulin commented
Tested, on latest master. Results:
Fixed:
- All the Riak proxy endpoints -
localhost:9000/riak/clusters/invalid/...
- Perfect. Returns 404, with JSON error:{"error":"Node is not running."}
. - List nodes -
curl localhost:9000/explore/clusters/invalid/nodes
now returns 404 (though with an HTML 'not found', rather than a JSON error). - Get bucket type's buckets, invalid cluster -
curl localhost:9000/explore/clusters/invalid/bucket_types/default/buckets
now returns 404 (though with an HTML 'not found', rather than a JSON error). - Get a bucket's key cache -
localhost:9000/explore/clusters/invalid/bucket_types/default/buckets/$bucket/keys
now returns 404 (though with an HTML 'not found', rather than a JSON error).
Not quite fixed:
- Get bucket type jobs, invalid cluster -
curl localhost:9000/explore/clusters/invalid/bucket_types/default/jobs
returns a 200 OK, with an empty jobs list. Should probably still be a 404 with the json error. - Get a bucket's jobs -
localhost:9000/explore/clusters/invalid/bucket_types/default/buckets/$bucket/jobs
- returns a 200 OK, with an empty jobs list. Should probably still be a 404 with the json error.
Still returns 500:
- List bucket types -
curl localhost:9000/explore/clusters/invalid/bucket_types
returns 500 - Get bucket type props, invalid cluster -
curl localhost:9000/explore/clusters/invalid/bucket_types/default
returns 500
drewkerrigan commented
Ok, I've addressed your comments.
dmitrizagidulin commented
Perfect, all fixed.
curl localhost:9000/riak/clusters/invalid/ping
-> 404 Not Found,{"error":"Cluster doesn't exist."}
curl localhost:9000/explore/clusters/invalid/nodes
-> 404 Not Found,{"error":"Cluster doesn't exist."}
curl localhost:9000/explore/clusters/invalid/bucket_types/default/buckets
-> 404 Not Found,{"error":"Cluster doesn't exist."}
curl localhost:9000/explore/clusters/invalid/bucket_types/default/buckets/users/keys
-> 404 Not Found,{"error":"Cluster doesn't exist."}
curl localhost:9000/explore/clusters/invalid/bucket_types/default/jobs
-> 404 Not Found,{"error":"Cluster doesn't exist."}
curl localhost:9000/explore/clusters/invalid/bucket_types/default/buckets/users/jobs
-> 404 Not Found,{"error":"Cluster doesn't exist."}
curl localhost:9000/explore/clusters/invalid/bucket_types
-> 404 Not Found,{"error":"Cluster doesn't exist."}
curl localhost:9000/explore/clusters/invalid/bucket_types/default
-> 404 Not Found,{"error":"Cluster doesn't exist."}
Closing.