-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
fix(feedback): parse JSON after checking status code #103167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,7 +46,6 @@ def generate_labels(feedback_message: str, organization_id: int) -> list[str]: | |
| timeout=SEER_TIMEOUT_S, | ||
| retries=SEER_RETRIES, | ||
| ) | ||
| response_data = response.json() | ||
| except Exception: | ||
| logger.exception("Seer failed to generate user feedback labels") | ||
| raise | ||
|
|
@@ -58,7 +57,5 @@ def generate_labels(feedback_message: str, organization_id: int) -> list[str]: | |
| ) | ||
| raise Exception("Seer returned non-200 response") | ||
|
|
||
| labels = response_data["data"]["labels"] | ||
|
|
||
| # Guaranteed to be a list of strings (validated in Seer) | ||
| return labels | ||
| return response.json()["data"]["labels"] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Error Handling Removes Vital Debugging ContextMoving |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,7 +35,6 @@ def is_spam_seer(message: str, organization_id: int) -> bool | None: | |
| timeout=SEER_TIMEOUT_S, | ||
| retries=SEER_RETRIES, | ||
| ) | ||
| response_data = response.json() | ||
| except Exception: | ||
| logger.exception("Seer failed to check if message is spam") | ||
| return None | ||
|
|
@@ -47,6 +46,7 @@ def is_spam_seer(message: str, organization_id: int) -> bool | None: | |
| ) | ||
| return None | ||
|
|
||
| response_data = response.json() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Unhandled JSON Errors Violate ContractMoving
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah... Should I wrap all the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| if ( | ||
| not isinstance(response_data, dict) | ||
| or "is_spam" not in response_data | ||
|
|
||
There was a problem hiding this comment.
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.