Skip to content
This repository has been archived by the owner on Mar 24, 2021. It is now read-only.

Commit

Permalink
Improve error message for empty JSON payload
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul M Furley committed May 8, 2014
1 parent bfcaa37 commit 533c347
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions backdrop/write/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,9 @@ def json_error_handler(e):
app.logger.exception(e)
abort(400, 'Error parsing JSON: "{}"'.format(str(e)))

if len(request.data) == 0:
abort(400, 'Expected JSON request body but received zero bytes.')

request.on_json_loading_failed = json_error_handler
return request.get_json()

Expand Down

0 comments on commit 533c347

Please sign in to comment.