mirror of https://github.com/zulip/zulip.git
migrations: Fix possible 0257_fix_has_link_attribute.py failure.
While it should be an invariant that message.rendered_content is never None for a row saved to the database, it is possible for that invariant to be violated, likely including due to bugs in previous versions of data import/export tools. While it'd be ideal for such messages to be rendered to fix the invariant, it doesn't make sense for this has_link migration to crash because of such a corrupted row, so we apply the similar policy we already have for rendered_content="".
This commit is contained in:
parent
f1d5f3904d
commit
285e10fe2f
|
@ -13,9 +13,9 @@ BATCH_SIZE = 1000
|
|||
def process_batch(apps: StateApps, id_start: int, id_end: int, last_id: int) -> None:
|
||||
Message = apps.get_model("zerver", "Message")
|
||||
for message in Message.objects.filter(id__gte=id_start, id__lte=id_end).order_by("id"):
|
||||
if message.rendered_content == "":
|
||||
if message.rendered_content in ["", None]:
|
||||
# There have been bugs in the past that made it possible
|
||||
# for a message to have "" as its rendered_content; we
|
||||
# for a message to have "" or None as its rendered_content; we
|
||||
# need to skip those because lxml won't process them.
|
||||
#
|
||||
# They should safely already have the correct state
|
||||
|
|
Loading…
Reference in New Issue