From bf9cb4403f290b1313a86a2dce1c81eb36a043b0 Mon Sep 17 00:00:00 2001 From: Jon Lee Date: Tue, 25 Jun 2024 00:01:08 +0800 Subject: [PATCH] fix: KeyError: 'g' when build_role_links --- casbin/model/policy.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/casbin/model/policy.py b/casbin/model/policy.py index 01a4d8a..5daeea3 100644 --- a/casbin/model/policy.py +++ b/casbin/model/policy.py @@ -44,8 +44,9 @@ def build_role_links(self, rm_map): return for ptype, ast in self["g"].items(): - rm = rm_map[ptype] - ast.build_role_links(rm) + rm = rm_map.get(ptype) + if rm: + ast.build_role_links(rm) def build_incremental_role_links(self, rm, op, sec, ptype, rules): if sec == "g":