From dcef372e4f2a646d721fbef08adc9a284dced04f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 27 Sep 2016 15:50:43 +0200 Subject: [PATCH] Gracefully handle project without node types. This can happen when a projection excludes node types. --- pillar/api/utils/authorization.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pillar/api/utils/authorization.py b/pillar/api/utils/authorization.py index 4ae160c1..4b5a21ff 100644 --- a/pillar/api/utils/authorization.py +++ b/pillar/api/utils/authorization.py @@ -155,7 +155,7 @@ def compute_aggr_permissions(collection_name, resource, check_node_type=None): project_permissions = project['permissions'] # Find the node type from the project. - node_type = next((node_type for node_type in project['node_types'] + node_type = next((node_type for node_type in project.get('node_types', ()) if node_type['name'] == node_type_name), None) if node_type is None: # This node type is not known, so doesn't give permissions. node_type_permissions = {}