-
Notifications
You must be signed in to change notification settings - Fork 222
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
Make bad request exception generic unless in debug mode (0.15) #1131
base: 0.15
Are you sure you want to change the base?
Conversation
Update in e1c522f: Use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @glye! Can you please check and make this change if good for you ?
Co-authored-by: Jeremiah VALERIE <[email protected]>
@mcg-web Hi, I have made the change as requested. Could you please review it? |
@mcg-web Hi, I have made the change as requested. Could you please review it? |
(This is a 0.15 port of #1128 The README is outdated and it's not entirely clear which branches are stable now, but it seems to be 0.15 and 1.0. I'm unsure if this will be accepted, I will add doc and possibly tests if there is some approval.)
Exceptions and specifically stack traces should not be shown in production. This bundle has a customisable error handler, but as the documentation states: "Only query parsed error won't be replaced.". I could make my own
Parser
override class which catches the exceptions in prod mode, but then how can I produce a usable JSON response? I needed to modify theGraphController
to do that.The fix is to check
kernel.debug
and catch bad request exceptions. If debug mode is enabled, it rethrows the exception (i.e. works as before). If disabled (prod mode), it instead returns ablankJsonResponse with HTTP 400 Bad Request status code and the exception message, but not the stack trace. The simplest manual test is to accessexample.com/graphql
in a browser, in debug and prod modes.If rejected, please let me know if you can see ways of doing this in my project without modifying your bundle. Thanks!
Related: It would also be nice to disable introspection in prod mode by default, like shown in the doc. But since it hasn't been done yet, I assume the maintainers aren't keen on it.