diff --git a/events/models.py b/events/models.py index e06115c..5fc039b 100644 --- a/events/models.py +++ b/events/models.py @@ -62,7 +62,10 @@ class Event(models.Model): # > allowed. Has to be lowercase. # But event.schema.json has this anyOf [..] null and only speaks of "it is strongly recommended to generate that # uuid4 clientside". In any case, we just rely on the envelope's event_id (required per the envelope spec). - # Not a primary key: events may be duplicated across projects + # Not a primary key: events may be duplicated across projects. (this may actually be a historical mistake, this + # literally stems from the very first version of the Event model. Presumably anticipating forwarding across projects + # or similar. One way out of this (and similar notes in issues/views.py) would be introducing a unique index on + # event_id, but (obviously) not without some migration path. event_id = models.UUIDField(primary_key=False, null=False, editable=False, help_text="As per the sent data") project = models.ForeignKey(Project, blank=False, null=False, on_delete=models.DO_NOTHING) diff --git a/issues/views.py b/issues/views.py index 8e591a7..3c14302 100644 --- a/issues/views.py +++ b/issues/views.py @@ -403,6 +403,10 @@ def _get_event(qs, issue, event_pk, digest_order, nav, bounds): try: return Event.objects.get(pk=event_pk) except Event.DoesNotExist: + # we match on external id "for user ergonomics" (presumed); i.e. in the (unchecked) presumption that people + # may sometimes copy/paste the SDK-generated UUID for whatever reason straight into the URL bar. However: + # [1] the below is not guaranteed unique and [2] it's not indexed as such so may be slow (project_id is a + # prefix in the index) so YMMV. return Event.objects.get(event_id=event_pk) elif digest_order is not None: