-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
fix: handle the case of invalid json gracefully #1581
Conversation
This changes the behaviour how invalid json is handled in the `/decide`-endpoint instead of failing hard by throwing a 500 internal server error it instead will throw a 400 Bad Request error instead to make the Developer Experience better fixes PostHog#1576
Originally I want to use a custom exception handler and return 400 when JSONError exception is thrown but I am seem to unable to get my exception handler to get called. The main reason for this approach to change the behaviour for all API routes. |
Ok so this right now works but is not the way I want to handle it because it adds redundancy through calling |
Ha, I've been hopping around timezones so my GitHub posts are happening "in the future". "Yakko self-requested a review in 1h" |
Ok so @weyert had mentioned that we should see if there are any other endpoints that could benefit from this approach. I think /capture potentially could. However, I'll merge this as it is somewhat "blocking" me on #1553 and then see with another PR the other endpoints this could be applied to. Thanks for this @weyert! I definitely agree we should be throwing as few 500s as possible. |
Thank you @yakkomajuri for looking and accepting my pull request :D |
This changes the behaviour how invalid json is handled in the
/decide
-endpoint instead of failing hard by throwing a 500 internal server error it instead will throw a 400 Bad Request error instead to make the Developer Experience betterfixes #1576
Changes
Please describe.
If this affects the front-end, include screenshots.
Checklist