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

When specifying a list of dataset names with dataset_name__in, API returns 400 Bad Request if any of the names don't exist #318

Open
brlodi opened this issue Jul 19, 2017 · 0 comments

Comments

@brlodi
Copy link
Collaborator

brlodi commented Jul 19, 2017

This is potentially not a bug, but is certainly a nomenclature issue.

Endpoints which accept dataset_name__in return a HTTP 400 Bad Request error if the passed list contains dataset names that don't exist or aren't the correct type. For example, .../timeseries?dataset_name__in=311_service_requests_rodent_baiting,foo and .../timeseries?dataset_name__in=311_service_requests_rodent_baiting,major_streets both trigger the error response, in the first case because foo isn't the name of any dataset and in the second because major_streets does exist but is a shape dataset.

From a semantic perspective, I would not expect dataset_name__in to need to only contain extant datasets of the correct type. The parameter reads as an in expression and so it is reasonable to expect it to carry the same semantics as in does in other cases:

Python

>>> 'a' in ['a', 'b', 'c']
True

Javascript

> 'b' in { a: 'foo', b: 'bar', c: 'baz' }
< true

Although I think there is utility in supporting the common understanding of in here, I recognize that the current behavior is likely much more performant. If we want to keep this implementation, however, I think this needs a different name with less confusing semantics (possibly as simple as a pluralized dataset_names field).

Relatedly, this is another apparent misuse of the HTTP 400 Bad Request error by the API. There is nothing wrong with the syntax of the HTTP request. Backend errors should not be arbitrarily mapped to HTTP status codes, which serve a specific purpose in governing the network communication. (I don't think this is a "bad request" anyway, since it's a value error not a structural one)

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

No branches or pull requests

1 participant