From 0807262e9f028f5ace10c6c336887d90e8e28bdd Mon Sep 17 00:00:00 2001
From: Brendan Abolivier <babolivier@matrix.org>
Date: Fri, 30 Oct 2020 12:05:58 +0000
Subject: [PATCH] Fix error handling around when completing an AS transaction

---
 changelog.d/8693.misc                        | 1 +
 synapse/storage/databases/main/appservice.py | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 100644 changelog.d/8693.misc

diff --git a/changelog.d/8693.misc b/changelog.d/8693.misc
new file mode 100644
index 000000000000..b588bdd3e213
--- /dev/null
+++ b/changelog.d/8693.misc
@@ -0,0 +1 @@
+Add more type hints to the application services code.
diff --git a/synapse/storage/databases/main/appservice.py b/synapse/storage/databases/main/appservice.py
index 26eef6eb6136..e550cbc86690 100644
--- a/synapse/storage/databases/main/appservice.py
+++ b/synapse/storage/databases/main/appservice.py
@@ -261,7 +261,7 @@ def _complete_appservice_txn(txn):
             # has probably missed some events), so whine loudly but still continue,
             # since it shouldn't fail completion of the transaction.
             last_txn_id = self._get_last_txn(txn, service.id)
-            if (txn_id + 1) != txn_id:
+            if (last_txn_id + 1) != txn_id:
                 logger.error(
                     "appservice: Completing a transaction which has an ID > 1 from "
                     "the last ID sent to this AS. We've either dropped events or "