Skip to content

fix: Handle JSONDecodeError gracefully in StarletteRequestExtractor#4226

Merged
sentrivana merged 2 commits into
getsentry:masterfrom
moodix:fix/handle-malformed-json-starlette
Apr 3, 2025
Merged

fix: Handle JSONDecodeError gracefully in StarletteRequestExtractor#4226
sentrivana merged 2 commits into
getsentry:masterfrom
moodix:fix/handle-malformed-json-starlette

Conversation

@moodix

@moodix moodix commented Apr 1, 2025

Copy link
Copy Markdown
Contributor

Previously, when encountering malformed JSON in request bodies, the json() method would raise a JSONDecodeError. This change updates the method to catch the exception and return None instead, providing more consistent behavior and preventing unexpected crashes.

Added a test case to verify this error handling behavior.

Previously, when encountering malformed JSON in request bodies, the json() method would
raise a JSONDecodeError. This change updates the method to catch the exception and
return None instead, providing more consistent behavior and preventing unexpected
crashes.

Added a test case to verify this error handling behavior.
@moodix
moodix marked this pull request as ready for review April 1, 2025 16:52
@moodix
moodix requested a review from a team as a code owner April 1, 2025 16:52

@sentrivana sentrivana left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @moodix!

@moodix

moodix commented Apr 3, 2025

Copy link
Copy Markdown
Contributor Author

@sentrivana Looks like the workflow might need approval

@sentrivana
sentrivana enabled auto-merge (squash) April 3, 2025 14:42
@sentrivana
sentrivana merged commit 2b3b82d into getsentry:master Apr 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants