From d4341a2d978ef9e391dd9f26cd2bf50ad1495fb2 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Tue, 5 Jul 2022 15:01:34 +0100 Subject: [PATCH] Return clearer error when no state NID exists for an event (#2555) --- roomserver/storage/shared/storage.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/roomserver/storage/shared/storage.go b/roomserver/storage/shared/storage.go index 5c633122d..3191280cb 100644 --- a/roomserver/storage/shared/storage.go +++ b/roomserver/storage/shared/storage.go @@ -263,6 +263,12 @@ func (d *Database) snapshotNIDFromEventID( ctx context.Context, txn *sql.Tx, eventID string, ) (types.StateSnapshotNID, error) { _, stateNID, err := d.EventsTable.SelectEvent(ctx, txn, eventID) + if err != nil { + return 0, err + } + if stateNID == 0 { + return 0, sql.ErrNoRows // effectively there's no state entry + } return stateNID, err }