Skip to content

Commit

Permalink
Merge pull request #974 from sirosen/update-for-bottle
Browse files Browse the repository at this point in the history
Fix for invalid JSON handling on latest 'bottle'
  • Loading branch information
lafrech authored Sep 11, 2024
2 parents 75839eb + 716723b commit 9e7ec13
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Changelog
Unreleased
**********

Bug fixes:

* Fix the handling of invalid JSON bodies in the ``bottle`` parser to support
``bottle`` versions ``>=0.13``.

Other changes:

* ``MultiDictProxy`` now inherits from ``MutableMapping`` rather than ``Mapping``.
Expand Down
5 changes: 5 additions & 0 deletions src/webargs/bottleparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ def _raw_load_json(self, req):
data = req.json
except AttributeError:
return core.missing
except bottle.HTTPError as err:
if err.body == "Invalid JSON":
self._handle_invalid_json_error(err, req)
else:
raise

# unfortunately, bottle does not distinguish between an empty body, "",
# and a body containing the valid JSON value null, "null"
Expand Down

0 comments on commit 9e7ec13

Please sign in to comment.