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

Misleading 428 HTTP Status Code #197

Open
moay opened this issue Apr 23, 2019 · 0 comments
Open

Misleading 428 HTTP Status Code #197

moay opened this issue Apr 23, 2019 · 0 comments

Comments

@moay
Copy link

moay commented Apr 23, 2019

Today I ran into an issue that caused a real headache and cost several hours. When deploying our project to a server, everything seemed to work fine, but when our form was included using an iframe, we got a 428 precondition required http error when getting the captcha image. No one ever encountered that server status, we had a lot of research to do.

In the end, we figured out that there actually was no precondition required and that the error is completely unrelated (in our case, the session cookie is not properly sent to the server on the image request, still figuring out why). The 428 is willingly thrown in the CaptchaController (https://github.com/Gregwar/CaptchaBundle/blob/master/Controller/CaptchaController.php#L76), but is misleading and not the correct status code to return here.

The definition of 428: The HTTP 428 Precondition Required response status code indicates that the server requires the request to be conditional. (taken from https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/428).

The error method is used to indicate that the session is not OK. It has nothing to do with request structure, If-Match headers or anything that should be causing a 428.

Solution: The correct status code for this issue should be 400, additionally, there shouldn't be an empty image but an error message indicating the problem (or an exception or something else in the logs).

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