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 grav fails, HTTP error should be returned instead of 200 #1291

Closed
AddaxSoft opened this issue Feb 3, 2017 · 5 comments
Closed

when grav fails, HTTP error should be returned instead of 200 #1291

AddaxSoft opened this issue Feb 3, 2017 · 5 comments

Comments

@AddaxSoft
Copy link

When grav fails due for example to file access error, error HTTP 200 is currently returned.
This behavior confuses health check system to think everything is alright :)

Instead an HTTP 5xx error should be returned instead, so the health check systems can trigger

@rhukster
Copy link
Member

rhukster commented Feb 6, 2017

Whenever there's an error, i'm seeing a 500 error returned as expected. Can you please provide an example of how to get an error with a 200 response?

@flaviocopes
Copy link
Contributor

flaviocopes commented Feb 6, 2017

I added the enhancement label because I could reproduce the problem, but after a bit of research this is a PHP-level thing, when display_errors is enabled, and/or xdebug is enabled, parse errors trigger a 200, seems so it's able to correctly display the error message. Non-parse errors are always correctly handled.

So, not a Grav issue, but an environment setting. (see https://bugs.php.net/bug.php?id=50921)

screen shot 2017-02-06 at 18 55 20

After disabling errors:

screen shot 2017-02-06 at 19 02 14

@AddaxSoft
Copy link
Author

OK, here is how to reproduce the problem:
when I change the owner of all folders to root, some dirs will lose the "write" permission automatically to www-data; hence Grav will complain about not being able to write to some folders.

Instead of displaying error 500, Grav displays a normal 200 with error page that some folders are not writable.

@flaviocopes
Copy link
Contributor

Oh ok that's the Problems plugin output. It can be fixed by adding a http_response_code(500); here: https://github.com/getgrav/grav-plugin-problems/blob/develop/problems.php#L121

Can you check if this solves your problem?

@AddaxSoft
Copy link
Author

AddaxSoft commented Feb 7, 2017

@flaviocopes yes it works as expected now!
The web server returns a HTTP-500 error WITH the explanation of the error instead of the HTTP-200

The health checker now reports a problem with the server in this case :)
image

image

Thank you!

flaviocopes added a commit to getgrav/grav-plugin-problems that referenced this issue Feb 7, 2017
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

3 participants