Browse Source

(onpremise) Fix `TypeError: a float is required` in 0024_auto_20191230_2052.py (#20810)

Fixes: getsentry/onpremise#366

If an on-premise user has migrated rapidly (within the past 90 days) from 9.0.0 to 9.1.2 to 10.x they may encounter a TypeError: a float is required error because the event.timestamp does not exist and None is not a valid posix timestamp.

This change ensures that a timestamp value is always present by filling it from the Postgres event table if it is missing from the event data in Node storage for some reason.
Thomas Wunderlich 4 years ago
parent
commit
f16792b75a
1 changed files with 5 additions and 0 deletions
  1. 5 0
      src/sentry/migrations/0024_auto_20191230_2052.py

+ 5 - 0
src/sentry/migrations/0024_auto_20191230_2052.py

@@ -11,6 +11,7 @@ from django.utils import timezone
 
 from sentry import options
 from sentry.eventstore.models import Event as NewEvent
+from sentry.utils.dates import to_timestamp
 
 
 def backfill_eventstream(apps, schema_editor):
@@ -53,6 +54,10 @@ def backfill_eventstream(apps, schema_editor):
         for event in _events:
             event.project = projects.get(event.project_id)
             event.group = groups.get(event.group_id)
+            # 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)
         eventstore.bind_nodes(_events, "data")
 
     if skip_backfill: