Skip to content

Commit c041fff

Browse files
author
Yalin Li
authored
[ACR] Fix a bug in list_tag and list_manifest in empty repository (Azure#29445)
1 parent adac067 commit c041fff

File tree

6 files changed

+63
-10
lines changed

6 files changed

+63
-10
lines changed

sdk/containerregistry/azure-containerregistry/CHANGELOG.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,19 @@
77
### Breaking Changes
88

99
### Bugs Fixed
10+
- Fixed a `TypeError` when call `list_tag()` in an empty repository. ([#28234](https://github.com/Azure/azure-sdk-for-python/issues/28234))
11+
- Fixed a `TypeError` when call `list_manifest()` in an empty repository. ([#28432](https://github.com/Azure/azure-sdk-for-python/issues/28432))
1012

1113
### Other Changes
12-
* Add default value `"https://management.azure.com"` to kwarg `audience` in `ContainerRegistryClient`. ([#22229](https://github.com/Azure/azure-sdk-for-python/issues/22229))
13-
* Python 3.6 is no longer supported. Please use Python version 3.7 or later.
14-
* Bumped minimum dependency on `azure-core` to `>=1.24.0`
15-
* Bumped minimum dependency on `msrest` to `>=0.7.1`
14+
- Added default value `"https://management.azure.com"` to kwarg `audience` in `ContainerRegistryClient`. ([#22229](https://github.com/Azure/azure-sdk-for-python/issues/22229))
15+
- Python 3.6 is no longer supported. Please use Python version 3.7 or later.
16+
- Bumped minimum dependency on `azure-core` to `>=1.24.0`
17+
- Bumped minimum dependency on `msrest` to `>=0.7.1`
1618

1719
## 1.1.0b1 (2022-05-10)
1820

1921
### Features Added
20-
- Support uploading and downloading OCI manifests and artifact blobs in synchronous `ContainerRegistryClient`. ([#24004](https://github.com/Azure/azure-sdk-for-python/pull/24004))
22+
- Supported uploading and downloading OCI manifests and artifact blobs in synchronous `ContainerRegistryClient`. ([#24004](https://github.com/Azure/azure-sdk-for-python/pull/24004))
2123
### Other Changes
2224

2325
- Fixed a spell error in a property of `RepositoryProperties` to `last_updated_on`.

sdk/containerregistry/azure-containerregistry/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "python",
44
"TagPrefix": "python/containerregistry/azure-containerregistry",
5-
"Tag": "python/containerregistry/azure-containerregistry_448865ae2e"
5+
"Tag": "python/containerregistry/azure-containerregistry_ea5ba77c3e"
66
}

sdk/containerregistry/azure-containerregistry/azure/containerregistry/_container_registry_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ def extract_data(pipeline_response):
335335
deserialized = self._client._deserialize( # pylint: disable=protected-access
336336
"AcrManifests", pipeline_response
337337
)
338-
list_of_elem = deserialized.manifests
338+
list_of_elem = deserialized.manifests or []
339339
if cls:
340340
list_of_elem = cls(list_of_elem)
341341
link = None
@@ -547,7 +547,7 @@ def prepare_request(next_link=None):
547547

548548
def extract_data(pipeline_response):
549549
deserialized = self._client._deserialize("TagList", pipeline_response) # pylint: disable=protected-access
550-
list_of_elem = deserialized.tag_attribute_bases
550+
list_of_elem = deserialized.tag_attribute_bases or []
551551
if cls:
552552
list_of_elem = cls(list_of_elem)
553553
link = None

sdk/containerregistry/azure-containerregistry/azure/containerregistry/aio/_async_container_registry_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ async def extract_data(pipeline_response):
313313
deserialized = self._client._deserialize( # pylint: disable=protected-access
314314
"AcrManifests", pipeline_response
315315
)
316-
list_of_elem = deserialized.manifests
316+
list_of_elem = deserialized.manifests or []
317317
if cls:
318318
list_of_elem = cls(list_of_elem)
319319
link = None
@@ -524,7 +524,7 @@ def prepare_request(next_link=None):
524524

525525
async def extract_data(pipeline_response):
526526
deserialized = self._client._deserialize("TagList", pipeline_response) # pylint: disable=protected-access
527-
list_of_elem = deserialized.tag_attribute_bases
527+
list_of_elem = deserialized.tag_attribute_bases or []
528528
if cls:
529529
list_of_elem = cls(list_of_elem)
530530
link = None

sdk/containerregistry/azure-containerregistry/tests/test_container_registry_client.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,31 @@ def test_set_audience(self, containerregistry_endpoint):
597597
with pytest.raises(ClientAuthenticationError):
598598
for repo in client.list_repository_names():
599599
pass
600+
601+
@acr_preparer()
602+
@recorded_by_proxy
603+
def test_list_tags_in_empty_repo(self, containerregistry_endpoint):
604+
with self.create_registry_client(containerregistry_endpoint) as client:
605+
# cleanup tags in ALPINE repo
606+
for tag in client.list_tag_properties(ALPINE):
607+
client.delete_tag(ALPINE, tag.name)
608+
609+
response = client.list_tag_properties(ALPINE)
610+
if response is not None:
611+
for tag in response:
612+
pass
613+
614+
@acr_preparer()
615+
@recorded_by_proxy
616+
def test_list_manifests_in_empty_repo(self, containerregistry_endpoint):
617+
with self.create_registry_client(containerregistry_endpoint) as client:
618+
# cleanup manifests in ALPINE repo
619+
for tag in client.list_tag_properties(ALPINE):
620+
client.delete_manifest(ALPINE, tag.name)
621+
response = client.list_manifest_properties(ALPINE)
622+
if response is not None:
623+
for manifest in response:
624+
pass
600625

601626

602627
def test_set_api_version():

sdk/containerregistry/azure-containerregistry/tests/test_container_registry_client_async.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,32 @@ async def test_set_audience(self, containerregistry_endpoint):
480480
with pytest.raises(ClientAuthenticationError):
481481
async for repo in client.list_repository_names():
482482
pass
483+
484+
@acr_preparer()
485+
@recorded_by_proxy_async
486+
async def test_list_tags_in_empty_repo(self, containerregistry_endpoint):
487+
async with self.create_registry_client(containerregistry_endpoint) as client:
488+
# cleanup tags in ALPINE repo
489+
async for tag in client.list_tag_properties(ALPINE):
490+
await client.delete_tag(ALPINE, tag.name)
491+
492+
response = client.list_tag_properties(ALPINE)
493+
if response is not None:
494+
async for tag in response:
495+
pass
496+
497+
@acr_preparer()
498+
@recorded_by_proxy_async
499+
async def test_list_manifests_in_empty_repo(self, containerregistry_endpoint):
500+
async with self.create_registry_client(containerregistry_endpoint) as client:
501+
# cleanup manifests in ALPINE repo
502+
async for tag in client.list_tag_properties(ALPINE):
503+
await client.delete_manifest(ALPINE, tag.name)
504+
505+
response = client.list_manifest_properties(ALPINE)
506+
if response is not None:
507+
async for manifest in response:
508+
pass
483509

484510

485511
async def test_set_api_version():

0 commit comments

Comments
 (0)