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 error message for unparseable realm ID in 0672.

Anders Kaseorg7a8fbca85e37
diff --git a/zerver/migrations/0672_fix_attachment_realm.py b/zerver/migrations/0672_fix_attachment_realm.py
index 56a66336641..703664620f9 100644
--- a/zerver/migrations/0672_fix_attachment_realm.py
+++ b/zerver/migrations/0672_fix_attachment_realm.py
@@ -39,15 +39,15 @@ def fix_attachment_realm(apps: StateApps, schema_editor: BaseDatabaseSchemaEdito
try:
realm_id = int(matches[0])
- if not Realm.objects.filter(id=realm_id).exists():
- # If the realm doesn't exist (e.g. due to deletion), we can't do anything.
- continue
except ValueError:
# Don't do anything if path_id doesn't start with a sensible realm id.
print(
- f"Encountered ValueError for realm_id {realm_id} inferred from path_id of attachment {attachment.id}"
+ f"Encountered ValueError for realm_id {matches[0]} inferred from path_id of attachment {attachment.id}"
)
continue
+ if not Realm.objects.filter(id=realm_id).exists():
+ # If the realm doesn't exist (e.g. due to deletion), we can't do anything.
+ continue
if realm_id == attachment.realm_id:
# It's already correct, nothing to do.