Return clearer error when no state NID exists for an event (#2555)

This commit is contained in:
Neil Alexander 2022-07-05 15:01:34 +01:00 committed by GitHub
parent 5087b36af0
commit d4341a2d97
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -263,6 +263,12 @@ func (d *Database) snapshotNIDFromEventID(
ctx context.Context, txn *sql.Tx, eventID string, ctx context.Context, txn *sql.Tx, eventID string,
) (types.StateSnapshotNID, error) { ) (types.StateSnapshotNID, error) {
_, stateNID, err := d.EventsTable.SelectEvent(ctx, txn, eventID) _, 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 return stateNID, err
} }