Skip to content

Conversation

@srest2021
Copy link
Member

@srest2021 srest2021 commented Nov 11, 2025

fixes a bunch of noisy JSONDecodeErrors in title gen, label gen, and spam detection that were happening because we tried to JSON decode 500 responses:
https://sentry.sentry.io/issues/6977994202/?query=%22jsondecodeerror%22&referrer=issue-stream
https://sentry.sentry.io/issues/6978011530/?query=%22jsondecodeerror%22&referrer=issue-stream
https://sentry.sentry.io/issues/6978011522/?query=%22jsondecodeerror%22&referrer=issue-stream
https://sentry.sentry.io/issues/6978011504/?query=%22jsondecodeerror%22&referrer=issue-stream

response.json() calls are now outside try/catch which SHOULD be safe because by the time we get here, the status code is 200. This pattern matches what's currently in organization_feedback_summary.py.

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 11, 2025
@srest2021 srest2021 marked this pull request as ready for review November 11, 2025 18:11
@srest2021 srest2021 requested a review from a team as a code owner November 11, 2025 18:11
)
return None

response_data = response.json()
Copy link
Contributor

Choose a reason for hiding this comment

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

Bug: Unhandled JSON Errors Violate Contract

Moving response.json() outside the try/except block means JSON parsing errors will now raise an unhandled exception instead of returning None as documented. The function's contract states it "Returns None if the request fails", but a JSONDecodeError will now propagate to callers instead of being gracefully handled.

Fix in Cursor Fix in Web

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah... Should I wrap all the response.json() in their own try/catch??

Copy link
Member

Choose a reason for hiding this comment

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

Imo we shouldnt do more try catches. We've been trying to move away from the blanket exc handlers when making seer requests, endpoints have their own handlers that should work fine

{"detail": "Failed to generate user feedback label groups"}, status=500
)
label_groups = response_data["data"]
label_groups = response.json()["data"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Bug: JSON data errors now unhandled.

Moving response.json()["data"] outside the try/except block means JSON parsing or key access errors will raise an unhandled exception instead of being caught and returning the intended 500 error response with proper logging. Previously these errors were caught by the exception handler at lines 222-225.

Fix in Cursor Fix in Web


# Guaranteed to be a list of strings (validated in Seer)
return labels
return response.json()["data"]["labels"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Bug: Error Handling Removes Vital Debugging Context

Moving response.json()["data"]["labels"] outside the try/except block means JSON parsing or key access errors will now raise without the contextual logging that previously occurred. Before, such failures were logged with "Seer failed to generate user feedback labels" before re-raising, providing important debugging context that is now lost.

Fix in Cursor Fix in Web

@codecov
Copy link

codecov bot commented Nov 12, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff             @@
##           master   #103167      +/-   ##
===========================================
- Coverage   80.70%    80.67%   -0.03%     
===========================================
  Files        9226      9207      -19     
  Lines      394041    393528     -513     
  Branches    25104     24999     -105     
===========================================
- Hits       317995    317483     -512     
- Misses      75598     75620      +22     
+ Partials      448       425      -23     

@srest2021 srest2021 merged commit 40299af into master Nov 12, 2025
66 checks passed
@srest2021 srest2021 deleted the srest2021/fix-json-decode-error branch November 12, 2025 20:20
andrewshie-sentry pushed a commit that referenced this pull request Nov 13, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Nov 28, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants