Return a non-fatal error to the federation API on a state regression

This commit is contained in:
Neil Alexander 2020-10-08 11:38:48 +01:00
parent 3e12f6e9c2
commit f8cf9fe2d6
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944

View file

@ -236,10 +236,12 @@ func (u *latestEventsUpdater) latestState() error {
if len(u.removed) > len(u.added) { if len(u.removed) > len(u.added) {
// This really shouldn't happen. // This really shouldn't happen.
// TODO: What is ultimately the best way to handle this situation? // TODO: What is ultimately the best way to handle this situation?
return fmt.Errorf( return &gomatrixserverlib.NotAllowed{
"invalid state delta wants to remove %d state but only add %d state (between state snapshots %d and %d)", Message: fmt.Sprintf(
len(u.removed), len(u.added), u.oldStateNID, u.newStateNID, "invalid state delta wants to remove %d state but only add %d state (between state snapshots %d and %d)",
) len(u.removed), len(u.added), u.oldStateNID, u.newStateNID,
),
}
} }
// Also work out the state before the event removes and the event // Also work out the state before the event removes and the event