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

Fixed bug where Listing Blobs with BlobTraits.Metadata would return B… #14861

Merged
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
1 change: 1 addition & 0 deletions sdk/storage/Azure.Storage.Blobs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 12.7.0-preview.1 (Unreleased)
- Fixed bug where Stream returned from AppendBlobClient.OpenWrite(), BlockBlobClient.OpenWrite() and PageBlobClient.OpenWrite() did not flush while disposing preventing compatibility with using keyword.
- Fixed bug where Listing Blobs with BlobTraits.Metadata would return BlobItems with null metadata instead of an empty dictionary if no metadata was present.

## 12.6.0 (2020-08-31)
- Fixed bug where BlobClient.Upload(), BlockBlobClient.Upload(), AppendBlobClient.AppendBlock(), and PageBlobClient.UploadPages() would deadlock if the content stream's position was not 0.
Expand Down
2 changes: 1 addition & 1 deletion sdk/storage/Azure.Storage.Blobs/src/BlobExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ internal static BlobItem ToBlobItem(this BlobItemInternal blobItemInternal)
IsLatestVersion = blobItemInternal.IsCurrentVersion,
Metadata = blobItemInternal.Metadata?.Count > 0
? blobItemInternal.Metadata
: null,
: new Dictionary<string, string>(),
Tags = blobItemInternal.BlobTags.ToTagDictionary(),
ObjectReplicationSourceProperties = blobItemInternal.ObjectReplicationMetadata?.Count > 0
? ParseObjectReplicationMetadata(blobItemInternal.ObjectReplicationMetadata)
Expand Down
19 changes: 18 additions & 1 deletion sdk/storage/Azure.Storage.Blobs/tests/ContainerClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1779,7 +1779,7 @@ public async Task ListBlobsFlatSegmentAsync_MaxResults()

// Assert
Assert.AreEqual(2, page.Values.Count);
Assert.IsTrue(page.Values.All(b => b.Metadata == null));
Assert.IsTrue(page.Values.All(b => b.Metadata.Count == 0));
}

[Test]
Expand Down Expand Up @@ -2107,6 +2107,23 @@ public async Task ListBlobsHierarchySegmentAsync_Metadata()
AssertDictionaryEquality(metadata, item.Blob.Metadata);
}

[Test]
public async Task ListBlobsHierarchySegmentAsync_Metadata_NoMetadata()
{
await using DisposingContainer test = await GetTestContainerAsync();

// Arrange
AppendBlobClient blob = InstrumentClient(test.Container.GetAppendBlobClient(GetNewBlobName()));
await blob.CreateAsync();

// Act
BlobHierarchyItem item = await test.Container.GetBlobsByHierarchyAsync(traits: BlobTraits.Metadata).FirstAsync();

// Assert
Assert.IsNotNull(item.Blob.Metadata);
Assert.AreEqual(0, item.Blob.Metadata.Count);
}

[Test]
[ServiceVersion(Min = BlobClientOptions.ServiceVersion.V2019_07_07)]
public async Task ListBlobsHierarchySegmentAsync_EncryptionScope()
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.