From d050ca4f3acd0e83b2e485b08da3bfa7905dde72 Mon Sep 17 00:00:00 2001
From: Megan Henning <meganhenning@flywheel.io>
Date: Thu, 27 Oct 2016 13:51:51 -0500
Subject: [PATCH] Fix bug loading jobs no acqusitions

---
 api/dao/containerstorage.py      | 2 ++
 api/handlers/containerhandler.py | 5 ++++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/api/dao/containerstorage.py b/api/dao/containerstorage.py
index cf1278e3..3b7dd431 100644
--- a/api/dao/containerstorage.py
+++ b/api/dao/containerstorage.py
@@ -50,6 +50,8 @@ class ContainerStorage(object):
 
     def get_container(self, _id, projection=None, get_children=False):
         cont = self.get_el(_id, projection=projection)
+        if cont is None:
+            raise APINotFoundException('Could not find {} {}'.format(self.cont_name, _id))
         if get_children:
             children = self.get_children(_id, projection=projection)
             cont[CHILD_MAP[self.cont_name]] = children
diff --git a/api/handlers/containerhandler.py b/api/handlers/containerhandler.py
index b8a084f9..a6a0a018 100644
--- a/api/handlers/containerhandler.py
+++ b/api/handlers/containerhandler.py
@@ -223,17 +223,20 @@ class ContainerHandler(base.RequestHandler):
                     }
                 ]
         """
-
         self.config = self.container_handler_configurations[cont_name]
         self.storage = self.config['storage']
         if cont_name != 'sessions':
             self.abort(400, 'Can only request jobs at the session level.')
 
         cont = self._get_container(cid, projection={'permissions': 0}, get_children=True)
+
         permchecker = self._get_permchecker(cont)
         permchecker(noop)('GET', cid)
 
         children = cont.get('acquisitions')
+        if not children:
+            return {}
+
         id_array = [str(c['_id']) for c in children]
         cont_array = [containerutil.ContainerReference('acquisition', cid) for cid in id_array]
 
-- 
GitLab