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

feat: improve error message when request has non UTF-8 characters in the body #559

Merged
merged 1 commit into from
May 21, 2022

Conversation

bethesque
Copy link
Member

The problem with the JSON body validation was that when an invalid UTF-8 character was found in the request body, an exception was raised with a message that included the entire request body, including the non UTF-8 character. When the error handler then attempted to render the exception message in JSON, it then caused another error to be raised. This meant that instead of a 400 response, the user was receiving a 500 response.

This change detects the non UTF-8 character and returns a helpful error message indicating where the invalid character is. It also adds a spec to ensure that every request that accepts JSON calls the appropriate validation method in malformed_request?.

@bethesque
Copy link
Member Author

cc: @Inksprout

@bethesque bethesque merged commit 3addc0c into master May 21, 2022
@bethesque bethesque deleted the feat/handle-non-utf-8-chars branch May 21, 2022 10:28
@bethesque
Copy link
Member Author

cc: @uglyog

@Inksprout
Copy link
Contributor

already merged but 🎉

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

Successfully merging this pull request may close these issues.

None yet

2 participants