changeset 2096:efe31f0881fb

core (memory/disco): recover getItems on bridge's discoItems method if an item is empty
author Goffi <goffi@goffi.org>
date Sun, 18 Dec 2016 16:28:44 +0100
parents 522c4c8903f9
children 4bc408b549cd
files src/memory/disco.py
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/memory/disco.py	Sun Dec 18 10:17:32 2016 +0100
+++ b/src/memory/disco.py	Sun Dec 18 16:28:44 2016 +0100
@@ -350,4 +350,11 @@
         profile = self.host.memory.getProfileName(profile_key)
         entity = jid.JID(entity_jid_s)
         disco_items = yield self.getItems(entity, profile=profile)
-        defer.returnValue([(item.entity.full(), item.nodeIdentifier or '', item.name or '') for item in disco_items])
+        try:
+            ret = [(item.entity.full(), item.nodeIdentifier or '', item.name or '') for item in disco_items]
+        except AttributeError:
+            log.error(u"error while getting items from {entity}, it may result from invalid item(s)".format(entity=entity.full()))
+            # second try by ignoring empty items
+            ret = [(item.entity.full(), item.nodeIdentifier or '', item.name or '') for item in disco_items if item.entity]
+
+        defer.returnValue(ret)