{Core} Remove the check on managed_by_tenants#17526
Merged
Conversation
fengzhou-msft
approved these changes
Mar 31, 2021
managed_by_tenantsmanaged_by_tenants
Collaborator
|
Remove check on managed_by_tenants |
bganapa
approved these changes
Apr 1, 2021
evelyn-ys
approved these changes
Apr 1, 2021
3 tasks
jiasli
commented
Jan 30, 2023
Comment on lines
+1379
to
+1380
| if s.managed_by_tenants is None: | ||
| s_dict[_MANAGED_BY_TENANTS] = None |
Member
Author
There was a problem hiding this comment.
Consider following steps:
- ARM REST API response omits
managedByTenants(or returns"managedByTenants": null, though never observed) - Python SDK will still have
managed_by_tenants: None - As a consequence, Azure CLI output will have
"managedByTenants": null
This behavior is a breaking change and doesn't comply with swagger as empty array [] becomes null (null is no longer an array), so users assuming managedByTenants to be an array may also face failure.
"managedByTenants": {
"type": "array",
"items": {
"$ref": "#/definitions/ManagedByTenant"
},
"description": "An array containing the tenants managing the subscription."
},Actually, there is no way to perfectly handle all kinds of REST API changes or behaviors in the gray area. In my humble opinion, making API consistent and comply with the swagger is the best and ultimate solution.
In this case,
managedByTenantsproperty MUST existmanagedByTenantsMUST be an array, notnull
https://learn.microsoft.com/en-us/rest/api/resources/subscriptions/list?tabs=HTTP
Member
Author
|
This PR has been shipped in Azure CLI 2.22.0. |
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
Fix #17509
When
latestor2019-06-01is used for Azure Stack/subscription, the REST response doesn't havemanagedByTenants. However, because the REST spec defines it, theSubscriptionobject returned by SDK will havemanaged_by_tenantsasNone. In such case, the behavior of this PR differs from the patch provided in {Core} Quick patch formanaged_by_tenantsmissing from response #17509:managed_by_tenantsmissing from response #17509: CLI doesn't returnmanagedByTenants, following the actual REST responsemanagedByTenants, but sets it tonull, following the REST specWhen
2019-03-01-hybridor2016-06-01is used for Azure Stack/subscription, the REST response doesn't havemanagedByTenants. Because the REST spec doesn't define it, theSubscriptionobject returned by SDK doesn't havemanaged_by_tenants, so CLI ignores it. This is the same as {Core} Quick patch formanaged_by_tenantsmissing from response #17509.Additional Context
When SDK object has
managed_by_tenantsasNone, CLI can't distinguish betweenmanagedByTenantsmanagedByTenantsasnull(Luckily, this has never been observed.)By disabling this check in the gatekeeper
az login, CLI may fail even deeper in other commands because the profile / API version is incorrect after all. The handling of unsupported API will be more difficult, but Azure Stack team confirms this is acceptable.