Azure / azure-sdk-for-net

This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.
MIT License
5.25k stars 4.59k forks source link

[BUG] `NullReferenceException` on parsing failure response from storage account #45427

Open xperiandri opened 1 month ago

xperiandri commented 1 month ago

Library name and version

Azure.Storage.Blobs 12.21.1

Describe the bug

Elements in XML come in the camel case which causes NullReferenceException here image

https://github.com/Azure/azure-sdk-for-net/blob/d18af43c36aa606280d3ba1cb6492b20844d182a/sdk/storage/Azure.Storage.Common/src/Shared/StorageRequestFailedDetailsParser.cs#L30

Expected behavior

Either Azure responds with the pascal case Or SDK handles camel case

Actual behavior

NullReferenceException

Reproduction Steps

var blobClient = new BlobServiceClient(optionsValue.StorageAccountUrl, new DefaultAzureCredential());
var containers = await blobClient.GetBlobContainersAsync(cancellationToken: cancellationToken).ToListAsync(cancellationToken);

Environment

.NET 8.0.303

github-actions[bot] commented 1 month ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @xgithubtriage.

xperiandri commented 1 month ago

I see here https://github.com/Azure/azure-sdk-for-net/blob/2fa9f855d9db1dbb46a63f7541a5f68529083163/sdk/storage/Azure.Storage.Blobs/src/Generated/ServiceRestClient.cs#L132 and here https://github.com/Azure/azure-sdk-for-net/blob/2fa9f855d9db1dbb46a63f7541a5f68529083163/sdk/storage/Azure.Storage.Blobs.Batch/src/ServiceRestClient.cs#L29 you hardcoded XML which makes it impossible to even workaround the issue 🤬😡😠🤦‍♂️

xperiandri commented 1 month ago

I used for blob new Uri($"https://{StorageAccountName}.table.core.windows.net/{containerName}/"); instead of new Uri($"https://{StorageAccountName}.blob.core.windows.net/{containerName}/");