diff --git a/konova/utils/exception_reporter.py b/konova/utils/exception_reporter.py index 46d26e4f..45a99e47 100644 --- a/konova/utils/exception_reporter.py +++ b/konova/utils/exception_reporter.py @@ -5,6 +5,9 @@ Contact: ksp-servicestelle@sgdnord.rlp.de Created on: 11.12.23 """ +import json +from json import JSONDecodeError + from django.views.debug import ExceptionReporter @@ -39,6 +42,8 @@ class KonovaExceptionReporter(ExceptionReporter): "raising_view_name", "exception_type", "exception_value", + "filtered_GET_items", + "filtered_POST_items", ] clean_data = dict() for entry in whitelist: @@ -56,7 +61,28 @@ class KonovaExceptionReporter(ExceptionReporter): """ tb_data = super().get_traceback_data() + return_data = tb_data if self.is_email: - tb_data = self._filter_traceback_data(tb_data) + filtered_data = dict() + filtered_data.update(self._filter_traceback_data(tb_data)) + filtered_data.update(self._filter_POST_body(tb_data)) + return_data = filtered_data + return return_data - return tb_data + def _filter_POST_body(self, tb_data: dict): + """ Filters POST body from traceback data + + """ + post_data = tb_data.get("request", None) + if post_data: + post_data = post_data.body + try: + post_data = json.loads(post_data) + except JSONDecodeError: + pass + post_data = { + "filtered_POST_items": [ + ("body", post_data), + ] + } + return post_data \ No newline at end of file