jenkins-bot has submitted this change and it was merged.

Change subject: get_slug_PHID: Catch list being empty and throw explanation
......................................................................


get_slug_PHID: Catch list being empty and throw explanation

Change-Id: Ie281f810c598e9b08e521275d16f7939e52b622c
---
M forrestbot.py
1 file changed, 9 insertions(+), 3 deletions(-)

Approvals:
  Merlijn van Deen: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/forrestbot.py b/forrestbot.py
index cfe8968..fabce93 100644
--- a/forrestbot.py
+++ b/forrestbot.py
@@ -80,9 +80,15 @@
 
 @functools.lru_cache()
 def get_slug_PHID(slug):
-    rq = list(
-        phab.request('project.query', {'slugs': [slug]})['slugMap'].values()
-    )
+    try:
+        rq = list(
+            phab.request('project.query', {'slugs': [slug]})['slugMap']
+                .values()
+        )
+    except AttributeError:
+        # If slugMap is empty, an empty list rather than an empty dict is
+        # returned by Phabricator.
+        raise Exception("No PHID found for slug #%s!" % slug)
     if rq:
         logging.debug(
             "Slug {slug} = PHID {phid}".format(slug=slug, phid=rq[0])

-- 
To view, visit https://gerrit.wikimedia.org/r/242369
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie281f810c598e9b08e521275d16f7939e52b622c
Gerrit-PatchSet: 2
Gerrit-Project: labs/tools/forrestbot
Gerrit-Branch: master
Gerrit-Owner: Jforrester <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Merlijn van Deen <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to