diff --git a/server/aap/publish/formatters/aap_apple_news_formatter.py b/server/aap/publish/formatters/aap_apple_news_formatter.py index 411fdf03b..da24b5493 100644 --- a/server/aap/publish/formatters/aap_apple_news_formatter.py +++ b/server/aap/publish/formatters/aap_apple_news_formatter.py @@ -106,7 +106,7 @@ def _remove_unwanted_embeds(self, article): # can only handle pictures at the moment for key, item in (article.get("associations") or {}).items(): - if key.startswith("editor_") and item.get("type") != 'picture': + if item and key.startswith("editor_") and item.get("type", "") != 'picture': remove_keys.append(key) self._remove_embeds(article, remove_keys) diff --git a/server/aap/publish/formatters/aap_apple_news_formatter_tests.py b/server/aap/publish/formatters/aap_apple_news_formatter_tests.py index f96512742..f4ac3f698 100644 --- a/server/aap/publish/formatters/aap_apple_news_formatter_tests.py +++ b/server/aap/publish/formatters/aap_apple_news_formatter_tests.py @@ -114,7 +114,8 @@ def test_format_article_with_embeds(self): 'Extinction Rebellion rally in Sydney, ' 'Thursday, October 31, 2019.'}, 'editor_0': {'type': 'video'}, - 'editor_1': {'type': 'picture'}} + 'editor_1': {'type': 'picture'}, + 'editor_2': None} article['fields_meta'] = { "body_html": { "draftjsState": [