Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle details "null" #19430

Merged
merged 2 commits into from
Jul 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sdk/core/azure-core/azure/core/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def __init__(self, json_object):

# details is recursive of this very format
self.details = [] # type: List[ODataV4Format]
for detail_node in json_object.get(cls.DETAILS_LABEL, []):
for detail_node in json_object.get(cls.DETAILS_LABEL) or []:
try:
self.details.append(self.__class__(detail_node))
except Exception: # pylint: disable=broad-except
Expand Down
13 changes: 13 additions & 0 deletions sdk/core/azure-core/tests/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,16 @@ def test_broken_odata_details(self):
}
exp = HttpResponseError(response=_build_response(json.dumps(message).encode("utf-8")))
assert exp.error.code == "Conflict"

def test_null_odata_details(self):
message = {
"error": {
"code": "501",
"message": "message",
"target": None,
"details": None,
"innererror": None,
}
}
exp = HttpResponseError(response=_build_response(json.dumps(message).encode("utf-8")))
assert exp.error.code == "501"