Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

migrations: Fix Nagios bot cleanup crash.

Tim Abbott07c927ae8844
diff --git a/zerver/migrations/0564_purge_nagios_messages.py b/zerver/migrations/0564_purge_nagios_messages.py
index 01137516f6c..ab381e1fa3c 100644
--- a/zerver/migrations/0564_purge_nagios_messages.py
+++ b/zerver/migrations/0564_purge_nagios_messages.py
@@ -23,12 +23,16 @@ def purge_nagios_messages(apps: StateApps, schema_editor: BaseDatabaseSchemaEdit
(settings.NAGIOS_STAGING_SEND_BOT, settings.NAGIOS_STAGING_RECEIVE_BOT),
]
for sender_email, recipient_email in nagios_bot_tuples:
- sender_id = UserProfile.objects.get(
- delivery_email=sender_email, realm_id=bot_realm.id
- ).id
- recipient_id = UserProfile.objects.get(
- delivery_email=recipient_email, realm_id=bot_realm.id
- ).recipient_id
+ try:
+ sender_id = UserProfile.objects.get(
+ delivery_email=sender_email, realm_id=bot_realm.id
+ ).id
+ recipient_id = UserProfile.objects.get(
+ delivery_email=recipient_email, realm_id=bot_realm.id
+ ).recipient_id
+ except UserProfile.DoesNotExist:
+ # If these special users don't exist, there's nothing to do.
+ continue
batch_size = 10000
while True: