[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) <tde@openerp.com>
This commit is contained in:
committed by
Mahamadasif Ansari
parent
6adab9556a
commit
6fe9cbba23
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user