Skip to content

Commit

Permalink
Fix crash on empty association due to kill (#1177)
Browse files Browse the repository at this point in the history
  • Loading branch information
marwoodandrew authored Aug 10, 2023
1 parent 3f26da3 commit 4847ea3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion newsroom/wire/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -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', [])]
Expand Down
3 changes: 2 additions & 1 deletion tests/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
'<p>Par 1</p><!-- EMBED START Audio {id: \"editor_0\"} --><figure>'
Expand Down

0 comments on commit 4847ea3

Please sign in to comment.