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

Cornice doesn't throw a bad request if error list is empty #530

Open
SabareeshKumar opened this issue Mar 3, 2020 · 0 comments
Open

Cornice doesn't throw a bad request if error list is empty #530

SabareeshKumar opened this issue Mar 3, 2020 · 0 comments

Comments

@SabareeshKumar
Copy link

Hi

I am writing a REST API using cornice. This is my code:

from pyramid.httpexceptions import HTTPBadRequest

@my_service.get(
    permission="my_permission",
    validators=(my_validator),
)
def my_service(request):
    # My code
    request.errors.status = HTTPBadRequest.code
    return

In the above API, I am explicitly setting the errors' status to Bad request.

But the API response status code is returned as 200.

When I add an error message into request.errors like (below), the status code is set properly.

request.errors.add('path', 'id', 'Invalid id')

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

1 participant