Skip to content

Commit 279d650

Browse files
authored
Avoid 500 Internal Server Error if empty body is posted to _dash-update_component (#458)
* Avoid 500 Internal Server Error if empty body is posted to _dash-update-component * Return HTTP status 200 if empty body is posted to _dash-update-component
1 parent f2f9a57 commit 279d650

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

django_plotly_dash/views.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
# pylint: disable=unused-argument
2626

2727
import json
28+
from json import JSONDecodeError
2829

2930
from django.http import HttpResponse, HttpResponseRedirect
3031
from django.shortcuts import redirect
@@ -79,7 +80,10 @@ def _update(request, ident, stateless=False, **kwargs):
7980
'Generate update json response'
8081
dash_app, app = DashApp.locate_item(ident, stateless)
8182

82-
request_body = json.loads(request.body.decode('utf-8'))
83+
try:
84+
request_body = json.loads(request.body.decode('utf-8'))
85+
except (JSONDecodeError, UnicodeDecodeError):
86+
return HttpResponse(status=200)
8387

8488
# Use direct dispatch with extra arguments in the argMap
8589
app_state = request.session.get("django_plotly_dash", dict())

0 commit comments

Comments
 (0)