Raise HTTP 422 if the submission doesn't parse. elo-categories
authorAnt Zucaro <azucaro@gmail.com>
Sat, 22 Apr 2017 19:50:48 +0000 (15:50 -0400)
committerAnt Zucaro <azucaro@gmail.com>
Sat, 22 Apr 2017 19:50:48 +0000 (15:50 -0400)
xonstat/views/submission.py

index a3bd3e3..e0ada1c 100644 (file)
@@ -1056,7 +1056,15 @@ def submit_stats(request):
                   "----- END REQUEST BODY -----\n\n")
 
         (idfp, status) = verify_request(request)
-        submission = Submission(request.body, request.headers)
+        try:
+            submission = Submission(request.body, request.headers)
+        except:
+            msg = "Invalid submission"
+            log.debug(msg)
+            raise pyramid.httpexceptions.HTTPUnprocessableEntity(
+                body=msg,
+                content_type="text/plain"
+            )
 
         do_precondition_checks(request.registry.settings, submission)