summary refs log tree commit diff
path: root/synapse/rest/client/v1/admin.py
diff options
context:
space:
mode:
authorRichard van der Hoff <1389908+richvdh@users.noreply.github.com>2018-04-30 15:03:59 +0100
committerGitHub <noreply@github.com>2018-04-30 15:03:59 +0100
commitcead75fae3f3942be52c91e501d9a4739e4973fb (patch)
treefd550e44b97382d0a0d9d80f1ab77ce0b87ff460 /synapse/rest/client/v1/admin.py
parentMerge pull request #3129 from matrix-org/matthew/fix_group_dups (diff)
parentadd guard for None on purge_history api (diff)
downloadsynapse-cead75fae3f3942be52c91e501d9a4739e4973fb.tar.xz
Merge pull request #3160 from krombel/fix_3076
add guard for None on purge_history api
Diffstat (limited to 'synapse/rest/client/v1/admin.py')
-rw-r--r--synapse/rest/client/v1/admin.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/synapse/rest/client/v1/admin.py b/synapse/rest/client/v1/admin.py
index 303419d281..efd5c9873d 100644
--- a/synapse/rest/client/v1/admin.py
+++ b/synapse/rest/client/v1/admin.py
@@ -168,11 +168,24 @@ class PurgeHistoryRestServlet(ClientV1RestServlet):
                 yield self.store.find_first_stream_ordering_after_ts(ts)
             )
 
-            (_, depth, _) = (
+            room_event_after_stream_ordering = (
                 yield self.store.get_room_event_after_stream_ordering(
                     room_id, stream_ordering,
                 )
             )
+            if room_event_after_stream_ordering:
+                (_, depth, _) = room_event_after_stream_ordering
+            else:
+                logger.warn(
+                    "[purge] purging events not possible: No event found "
+                    "(received_ts %i => stream_ordering %i)",
+                    ts, stream_ordering,
+                )
+                raise SynapseError(
+                    404,
+                    "there is no event to be purged",
+                    errcode=Codes.NOT_FOUND,
+                )
             logger.info(
                 "[purge] purging up to depth %i (received_ts %i => "
                 "stream_ordering %i)",