Skip to content

Commit

Permalink
fix(snuba-migration): Add try-except for invalid groups (#22221)
Browse files Browse the repository at this point in the history
  • Loading branch information
BYK committed Nov 23, 2020
1 parent e831e03 commit 3948552
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/sentry/migrations/0024_auto_20191230_2052.py
Expand Up @@ -57,7 +57,7 @@ def _attach_related(_events):
# When migrating old data from Sentry 9.0.0 to 9.1.2 to 10 in rapid succession, the event timestamp may be
# missing. This adds it back
if "timestamp" not in event.data.data:
event.data.data['timestamp'] = to_timestamp(event.datetime)
event.data.data["timestamp"] = to_timestamp(event.datetime)
eventstore.bind_nodes(_events, "data")

if skip_backfill:
Expand All @@ -78,9 +78,16 @@ def _attach_related(_events):
event = NewEvent(
project_id=e.project_id, event_id=e.event_id, group_id=e.group_id, data=e.data.data
)
primary_hash = event.get_primary_hash()
if event.project is None or event.group is None or len(event.data) == 0:
print("Skipped {} as group, project or node data information is invalid.\n".format(event))

try:
group = event.group
except Group.DoesNotExist:
group = None

if event.project is None or group is None or len(event.data) == 0:
print(
"Skipped {} as group, project or node data information is invalid.\n".format(event)
)
continue

try:
Expand All @@ -90,7 +97,7 @@ def _attach_related(_events):
is_new=False,
is_regression=False,
is_new_group_environment=False,
primary_hash=primary_hash,
primary_hash=event.get_primary_hash(),
received_timestamp=event.data.get("received")
or float(event.datetime.strftime("%s")),
skip_consume=True,
Expand All @@ -107,7 +114,6 @@ def _attach_related(_events):
event.data.save()
nodestore.delete(old_node_id)


processed += 1
except Exception as error:
print(
Expand Down

0 comments on commit 3948552

Please sign in to comment.