Skip to content

Commit

Permalink
Handle MultiPartParserError to avoid internal sentry crash (#4001)
Browse files Browse the repository at this point in the history
Handles an internal error in sentry_sdk if there is an issue with
parsing request.POST.

It would be better to handle this exception without request data instead
of crashing and not reporting anything.

---

Co-authored-by: Ivana Kellyer <[email protected]>
  • Loading branch information
orhanhenrik and sentrivana authored Jan 31, 2025
1 parent 8c25c73 commit 91bf322
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions sentry_sdk/integrations/_wsgi_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,15 @@ def form(self):

def parsed_body(self):
# type: () -> Optional[Dict[str, Any]]
form = self.form()
files = self.files()
try:
form = self.form()
except Exception:
form = None
try:
files = self.files()
except Exception:
files = None

if form or files:
data = {}
if form:
Expand Down

0 comments on commit 91bf322

Please sign in to comment.