-
Notifications
You must be signed in to change notification settings - Fork 3.4k
{Core} aaz: Fix MgmtErrorFormat missing message from response
#32927
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -133,7 +133,7 @@ def __init__(self, json_object): | |||||||||
| # ARM specific annotations | ||||||||||
| self.additional_info = [ | ||||||||||
| TypedErrorInfo(additional_info["type"], additional_info["info"]) | ||||||||||
| for additional_info in self.get_object_prop(json_object, self.ADDITIONALINFO_LABEL, []) | ||||||||||
| for additional_info in self.get_object_prop(json_object, self.ADDITIONALINFO_LABEL, []) or [] | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If ADDITIONALINFO_LABEL can be present but null, do we want additional_info to end up as None or consistently as an empty list? I don’t have a preference.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's a workaround to make it iterable in the list comprehension, previously there is an implicit error: TypeError: 'NoneType' object is not iterablebtw, the actual logic of azure-cli/src/azure-cli-core/azure/cli/core/aaz/_error_format.py Lines 142 to 145 in e6e616f
|
||||||||||
| ] | ||||||||||
|
|
||||||||||
| def __str__(self): | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
| import unittest | ||
|
|
||
| from azure.cli.core.aaz._error_format import AAZMgmtErrorFormat | ||
|
|
||
|
|
||
| class TestMgmtErrorFormat(unittest.TestCase): | ||
| def test_additional_info_is_null(self): | ||
| response = { | ||
| "code": "BadRequest", | ||
| "message": "Test.", | ||
| "target": None, | ||
| "details": None, | ||
| "additionalInfo": None | ||
| } | ||
|
|
||
| error = AAZMgmtErrorFormat(response) | ||
| self.assertTrue(str(error) == '(BadRequest) Test.\nCode: BadRequest\nMessage: Test.') |
Uh oh!
There was an error while loading. Please reload this page.