From e86a6a9d254df6c041c14edcb15a03e7bdb73ee2 Mon Sep 17 00:00:00 2001 From: John Nduli Date: Wed, 31 Jul 2024 11:34:26 +0300 Subject: fix: dynamically get the keys that may contain error messages --- gn2/wqflask/oauth2/request_utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'gn2') diff --git a/gn2/wqflask/oauth2/request_utils.py b/gn2/wqflask/oauth2/request_utils.py index 167d0cbd..673a7da9 100644 --- a/gn2/wqflask/oauth2/request_utils.py +++ b/gn2/wqflask/oauth2/request_utils.py @@ -41,8 +41,10 @@ def process_error(error: Response, if error.status_code in range(400, 500): try: err = error.json() - msg = err.get( - "error_message", err.get("error_description", f"{error.reason}")) + potential_keys = [key for key in err.keys() if key.startswith("error")] + msg = f"{error.reason}" + if potential_keys: + msg = " ; ".join([f"{k}: {err[k]}" for k in potential_keys]) except simplejson.errors.JSONDecodeError as _jde: msg = message return { -- cgit v1.2.3