Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion debug_toolbar/panels/history/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ def generate_stats(self, request, response):
and request.body
and request.META.get("CONTENT_TYPE") == "application/json"
):
data = json.loads(request.body)
try:
data = json.loads(request.body)
except ValueError:
pass
except RawPostDataException:
# It is not guaranteed that we may read the request data (again).
data = None
Expand Down
6 changes: 6 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ unreleased
----------

* Moved CI to GitHub Actions: https://github.com/jazzband/django-debug-toolbar/actions
* Stopped crashing when ``request.GET`` and ``request.POST`` are
dictionaries instead of ``QueryDict`` instances. This isn't a valid
use of Django but django-debug-toolbar shouldn't crash anyway.
* Fixed a crash in the history panel when sending a JSON POST request
with invalid JSON.


3.2a1 (2020-10-19)
------------------
Expand Down
3 changes: 2 additions & 1 deletion tests/panels/test_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ def test_post(self):
def test_post_json(self):
for data, expected_stats_data in (
({"foo": "bar"}, {"foo": "bar"}),
("", {}),
("", {}), # Empty JSON
("'", {}), # Invalid JSON
):
with self.subTest(data=data):
self.request = rf.post(
Expand Down