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

Raise BadRequest rather than AssertionError in MongoEngineResource.dispatch() #66

Open
dcooper opened this issue Sep 21, 2013 · 1 comment

Comments

@dcooper
Copy link

dcooper commented Sep 21, 2013

If an API client sends an invalid request to the API server, the server should return a 4xx response rather than a 5xx response.

The dispatch() method on MongoEngineResource raises AssertionError when testing the request method. If dispatch() was to raise tastypie_exceptions.BadRequest rather than AssertionError, then tastypie will return an HTTP 400 to the client rather than an HTTP 500.

In the 0.4.2 version of tastypie_mongoengine, the AssertionError exceptions are raised in the following places:
tastypie_mongoengine/resources.py:373
tastypie_mongoengine/resources.py:376

@mitar
Copy link
Member

mitar commented Sep 21, 2013

Are you sure this should not be checked already in Tastypie? Here is assert just to assure we are using Tastypie API properly.

But if you want, you can make a pull request with this change and please add tests which send invalid requests and fail.

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

No branches or pull requests

2 participants