raiden icon indicating copy to clipboard operation
raiden copied to clipboard

API - return null values instead of 404 if no query-entities are found

Open ezdac opened this issue 4 years ago • 1 comments

Abstract

The e.g. GET /channels/ endpoint provides an endpoint for a set of all channels the node is connected to. It provides further filtering with token and partner_address URI parameters - filtering the resulting set of entities. In my opinion, when the user queries e.g. /channels/<token_address>/<partner_address> and no channel exists, the empty set [ ] should be returned instead of a 404 status code.

Motivation

The reasoning behind this:

  • The /channels endpoint is an endpoint for a set of entities, it does not refer to a unique resource like e.g. GET /channel/<id> would
  • 404 status codes usually imply user/client error
  • the /channels resource exists, but has no entities in it for the specific query ("empty database table, but the table exists")

Backwards Compatibility

Probably not backwards compatible, since this concerns the public API, and API consumers could already be catching the 404 error in order to handle missing channels.

ezdac avatar Nov 09 '20 14:11 ezdac

We could also return 404 and an empty list at the same time.

karlb avatar Nov 18 '21 14:11 karlb