diff --git a/firetail/decorators/response.py b/firetail/decorators/response.py index bdd91ff..cdfb2d4 100644 --- a/firetail/decorators/response.py +++ b/firetail/decorators/response.py @@ -115,11 +115,16 @@ def validate_response_authz(self, response_definition, data): return True def extract_item(self, data, response_data_lookup): - items = response_data_lookup.split(".") - dc = data.copy() - for i in items: - dc = dc[i] - return dc + try: + items = response_data_lookup.split(".") + dc = data.copy() + for i in items: + dc = dc[i] + return dc + except KeyError: + raise AuthzNotPopulated("Authz data does not contain expected key for authz to be evaluated") + except Exception: + raise AuthzFailed() def is_json_schema_compatible(self, response_schema: dict) -> bool: """