Bug 1401183: raise KeyError from list_artifacts when none is found; r?glandium draft
authorDustin J. Mitchell <dustin@mozilla.com>
Thu, 14 Sep 2017 23:30:58 +0000
changeset 667765 9a3030c8e4ecb532cad3fe2e03c4223ede060a5c
parent 666884 e4261f5b96ebfd63e7cb8af3035ff9fea90c74a5
child 732501 6dd0aed08478d8f6192d1426a515af22a9f161a3
push id80837
push userdmitchell@mozilla.com
push dateWed, 20 Sep 2017 18:07:49 +0000
reviewersglandium
bugs1401183
milestone57.0a1
Bug 1401183: raise KeyError from list_artifacts when none is found; r?glandium MozReview-Commit-ID: TqON8joEd6
taskcluster/taskgraph/util/taskcluster.py
--- a/taskcluster/taskgraph/util/taskcluster.py
+++ b/taskcluster/taskgraph/util/taskcluster.py
@@ -78,17 +78,22 @@ def get_index_url(index_path, use_proxy=
     if use_proxy:
         INDEX_URL = 'http://taskcluster/index/v1/task/{}'
     else:
         INDEX_URL = 'https://index.taskcluster.net/v1/task/{}'
     return INDEX_URL.format(index_path)
 
 
 def find_task_id(index_path, use_proxy=False):
-    response = _do_request(get_index_url(index_path, use_proxy))
+    try:
+        response = _do_request(get_index_url(index_path, use_proxy))
+    except requests.exceptions.HTTPError as e:
+        if e.response.status_code == 404:
+            raise KeyError("index path {} not found".format(index_path))
+        raise
     return response.json()['taskId']
 
 
 def get_artifact_from_index(index_path, artifact_path, use_proxy=False):
     full_path = index_path + '/artifacts/' + artifact_path
     response = _do_request(get_index_url(full_path, use_proxy))
     return _handle_artifact(full_path, response)