Skip to content

Commit 3a839e6

Browse files
author
Rebecka Gulliksson
committed
Don't catch KeyError over too broad statement.
Previously KeyError in lower level of implementation, MetadataStore.entity_categories(), was caught instead of being propagated.
1 parent 255c34e commit 3a839e6

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/saml2/assertion.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -273,13 +273,8 @@ def post_entity_categories(maps, **kwargs):
273273
required = []
274274

275275
if kwargs["mds"]:
276-
try:
276+
if "sp_entity_id" in kwargs:
277277
ecs = kwargs["mds"].entity_categories(kwargs["sp_entity_id"])
278-
except KeyError:
279-
for ec_map in maps:
280-
for attr in ec_map[""]:
281-
restrictions[attr] = None
282-
else:
283278
for ec_map in maps:
284279
for key, (atlist, only_required) in ec_map.items():
285280
if key == "": # always released
@@ -305,6 +300,10 @@ def post_entity_categories(maps, **kwargs):
305300

306301
for attr in attrs:
307302
restrictions[attr] = None
303+
else:
304+
for ec_map in maps:
305+
for attr in ec_map[""]:
306+
restrictions[attr] = None
308307

309308
return restrictions
310309

0 commit comments

Comments
 (0)