Skip to content

Commit 02a280d

Browse files
authored
{Core} aaz: Fix MgmtErrorFormat missing message from response (#32927)
1 parent 463730a commit 02a280d

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/azure-cli-core/azure/cli/core/aaz/_error_format.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def __init__(self, json_object):
133133
# ARM specific annotations
134134
self.additional_info = [
135135
TypedErrorInfo(additional_info["type"], additional_info["info"])
136-
for additional_info in self.get_object_prop(json_object, self.ADDITIONALINFO_LABEL, [])
136+
for additional_info in self.get_object_prop(json_object, self.ADDITIONALINFO_LABEL, []) or []
137137
]
138138

139139
def __str__(self):
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
# --------------------------------------------------------------------------------------------
5+
import unittest
6+
7+
from azure.cli.core.aaz._error_format import AAZMgmtErrorFormat
8+
9+
10+
class TestMgmtErrorFormat(unittest.TestCase):
11+
def test_additional_info_is_null(self):
12+
response = {
13+
"code": "BadRequest",
14+
"message": "Test.",
15+
"target": None,
16+
"details": None,
17+
"additionalInfo": None
18+
}
19+
20+
error = AAZMgmtErrorFormat(response)
21+
self.assertTrue(str(error) == '(BadRequest) Test.\nCode: BadRequest\nMessage: Test.')

0 commit comments

Comments
 (0)