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

Body parser now raises proper error on invalid request body #1981

Merged
merged 1 commit into from
Dec 18, 2020

Conversation

telday
Copy link
Contributor

@telday telday commented Dec 17, 2020

Fixes issues where 500 error was raised when application/json
Content-Type header was specified with empty or malformed request body

What does this PR do?

Adds error handling for malformed JSON body in request which will nicely catch the error then return a 400 error code rather than a 500 error.

What ticket does this PR close?

Resolves #1968

Checklists

Change log

  • The CHANGELOG has been updated, or
  • This PR does not include user-facing changes and doesn't require a CHANGELOG update

Test coverage

  • This PR includes new unit and integration tests to go with the code changes, or
  • The changes in this PR do not require tests

Documentation

  • Docs (e.g. READMEs) were updated in this PR, and/or there is a follow-on issue to update docs, or
  • This PR does not require updating any documentation

@telday telday requested a review from a team as a code owner December 17, 2020 21:08
Copy link
Contributor

@micahlee micahlee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great @telday, thanks for putting this together!

Mind adding a CHANGELOG entry for this fix and rebasing? Then it should be good to go.

Fixes issues where 500 error was raised when application/json
Content-Type header was specified with empty request body
@codeclimate
Copy link

codeclimate bot commented Dec 18, 2020

Code Climate has analyzed commit d3956cb and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 75.0% (50% is the threshold).

This pull request will bring the total coverage in the repository to 86.4%.

View more on Code Climate.

@micahlee micahlee merged commit 895d2b9 into master Dec 18, 2020
@micahlee micahlee deleted the request-body-fix branch December 18, 2020 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Conjur returns 500 error on empty request body
2 participants