From 6fe9cbba23b8db4f5bc06a4b5a524473fc582990 Mon Sep 17 00:00:00 2001 From: Astik Singh Date: Thu, 27 Jul 2023 12:31:17 +0530 Subject: [PATCH] [FIX] microsoft_account: always return dictionary on API calls The return type of _do_request is inconsistent when an error is encountered. This causes issues when the callers expect the return type to be a dictionary consistently. We fix this by always returning an empty dictionary for the request response when encountering an error sentry-4339147124 closes odoo/odoo#136881 X-original-commit: f8ac76906d1eec2ad1bc1243f60998fe50caa1bc Signed-off-by: Thibault Delavallee (tde) --- addons/microsoft_account/models/microsoft_service.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/microsoft_account/models/microsoft_service.py b/addons/microsoft_account/models/microsoft_service.py index 14fd2650fb4..68d17d667b7 100644 --- a/addons/microsoft_account/models/microsoft_service.py +++ b/addons/microsoft_account/models/microsoft_service.py @@ -151,7 +151,7 @@ class MicrosoftService(models.AbstractModel): status = res.status_code if int(status) in RESOURCE_NOT_FOUND_STATUSES: - response = False + response = {} else: # Some answers return empty content response = res.content and res.json() or {} @@ -163,7 +163,7 @@ class MicrosoftService(models.AbstractModel): except requests.HTTPError as error: if error.response.status_code in RESOURCE_NOT_FOUND_STATUSES: status = error.response.status_code - response = "" + response = {} else: _logger.exception("Bad microsoft request: %s!", error.response.content) raise error