Skip to content

Commit

Permalink
Fix minor issues found in review
Browse files Browse the repository at this point in the history
  • Loading branch information
willkg committed May 19, 2024
1 parent 61fb2aa commit a3acf10
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/kent/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,13 @@ class Event:
project_id: int
event_id: str

# Dict with subdicts: envelope_header, header, body
# envelope_header when the envelope API is used
envelope_header: Optional[dict] = None
# item header
header: Optional[dict] = None
# item
# attachments will be stored as bytes, non-attachments as python
# datastructures
body: Optional[Union[dict, bytes]] = None

@property
Expand All @@ -77,6 +81,11 @@ def summary(self):
return "no summary"

if isinstance(self.body, dict):
# Kent body parsing errors
kent_error = self.body.get("error")
if kent_error:
return kent_error

# Sentry exceptions events
exceptions = deep_get(self.body, "exception.values", default=[])
if exceptions:
Expand Down Expand Up @@ -264,7 +273,11 @@ def store_view(project_id):
except Exception:
app.logger.exception("%s: exception when JSON-decoding body.", event_id)
app.logger.error("%s: %s", event_id, json_body)
body = {"error": "Kent could not decode body; see logs"}
EVENTS.add_event(
event_id=event_id,
project_id=project_id,
body={"error": "Kent could not decode body; see logs"},
)
raise

EVENTS.add_event(event_id=event_id, project_id=project_id, body=json_body)
Expand Down Expand Up @@ -363,7 +376,11 @@ def security_view(project_id):
except Exception:
app.logger.exception("%s: exception when JSON-decoding body.", event_id)
app.logger.error("%s: %s", event_id, body)
body = {"error": "Kent could not decode body; see logs"}
EVENTS.add_event(
event_id=event_id,
project_id=project_id,
body={"error": "Kent could not decode body; see logs"},
)
raise

EVENTS.add_event(event_id=event_id, project_id=project_id, body=json_body)
Expand Down

0 comments on commit a3acf10

Please sign in to comment.