From 4847ea3f7bc1b2e04d626194a64de47bf5c1f710 Mon Sep 17 00:00:00 2001 From: Andrew Marwood Date: Thu, 10 Aug 2023 15:44:21 +1000 Subject: [PATCH] Fix crash on empty association due to kill (#1177) --- newsroom/wire/search.py | 2 +- tests/test_download.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/newsroom/wire/search.py b/newsroom/wire/search.py index 1573b428..e15e9beb 100644 --- a/newsroom/wire/search.py +++ b/newsroom/wire/search.py @@ -551,7 +551,7 @@ def permission_embeds_in_item(self, item, permitted_products): """ disable_download = [] for key, embed_item in item.get("associations", {}).items(): - if key.startswith("editor_") and embed_item.get('type') in ['audio', 'video']: + if key.startswith("editor_") and embed_item and (embed_item.get('type', '')) in ['audio', 'video']: # get the list of products that the embedded item matched in Superdesk embed_products = [p.get('code') for p in ((item.get('associations') or {}).get(key) or {}).get('products', [])] diff --git a/tests/test_download.py b/tests/test_download.py index 585a625b..01f4f354 100644 --- a/tests/test_download.py +++ b/tests/test_download.py @@ -221,7 +221,8 @@ def setup_embeds(client, app): } }, "products": [{"code": "888"}] - } + }, + "editor_3": None } app.data.update('items', item['_id'], {'associations': associations, 'body_html': '

Par 1

'