From e9ccf6b67114c697fab89c3a06a450fddfde2be3 Mon Sep 17 00:00:00 2001 From: Ant Zucaro Date: Sat, 22 Apr 2017 15:50:48 -0400 Subject: [PATCH] Raise HTTP 422 if the submission doesn't parse. --- xonstat/views/submission.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/xonstat/views/submission.py b/xonstat/views/submission.py index a3bd3e3..e0ada1c 100644 --- a/xonstat/views/submission.py +++ b/xonstat/views/submission.py @@ -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) -- 2.39.2