azure-sdk-for-net
azure-sdk-for-net copied to clipboard
[BUG] Inaccurate error message "The specified container does not exist" when uploading data with empty blob name using BlobClient.
Library name and version
Azure.Storage.Blobs 12.14.0
Describe the bug
I created a BlobClient
by constructor BlobClient(string connectionString, string blobContainerName, string blobName)
with parameter blobName
set to an empty string.
When I call UploadAsync(BinaryData content)
, it shows the error message "The specified container does not exist". But I did have the container created.
Expected behavior
I think the error message should indicate the blob name cannot be null or empty.
Actual behavior
Azure.RequestFailedException: The specified container does not exist.
RequestId:aa50a74f-901e-003c-3647-e776e0000000
Time:2022-10-24T01:23:27.7599225Z
Status: 404 (The specified container does not exist.)
ErrorCode: ContainerNotFound
Content:
<?xml version="1.0" encoding="utf-8"?><Error><Code>ContainerNotFound</Code><Message>The specified container does not exist.
RequestId:aa50a74f-901e-003c-3647-e776e0000000
Time:2022-10-24T01:23:27.7599225Z</Message></Error>
Headers:
Server: Windows-Azure-Blob/1.0,Microsoft-HTTPAPI/2.0
x-ms-request-id: aa50a74f-901e-003c-3647-e776e0000000
x-ms-client-request-id: 89117e0d-204d-4525-a842-8ef0485e58f7
x-ms-version: 2021-10-04
x-ms-error-code: ContainerNotFound
Date: Mon, 24 Oct 2022 01:23:26 GMT
Content-Length: 225
Content-Type: application/xml
Reproduction Steps
Code to reproduce:
var connectingString = // Storage account connection string.
var blobContainerName = // Blob container name.
var blobName = "";
var filePath = // A file path.
var blobClient = new BlobClient(connectingString , blobContainerName, blobName);
var bytes = System.IO.File.ReadAllBytes(filePath);
await blobClient.UploadAsync(new System.BinaryData(bytes));
In the above code, I set the blobName
to an Empty string. I did have a blobContainerName created already. It returns error:
Azure.RequestFailedException: The specified container does not exist.
RequestId:aa50a74f-901e-003c-3647-e776e0000000
Time:2022-10-24T01:23:27.7599225Z
Status: 404 (The specified container does not exist.)
ErrorCode: ContainerNotFound
Content:
<?xml version="1.0" encoding="utf-8"?><Error><Code>ContainerNotFound</Code><Message>The specified container does not exist.
RequestId:aa50a74f-901e-003c-3647-e776e0000000
Time:2022-10-24T01:23:27.7599225Z</Message></Error>
Headers:
Server: Windows-Azure-Blob/1.0,Microsoft-HTTPAPI/2.0
x-ms-request-id: aa50a74f-901e-003c-3647-e776e0000000
x-ms-client-request-id: 89117e0d-204d-4525-a842-8ef0485e58f7
x-ms-version: 2021-10-04
x-ms-error-code: ContainerNotFound
Date: Mon, 24 Oct 2022 01:23:26 GMT
Content-Length: 225
Content-Type: application/xml
I think the error message can be improved to maybe "The specified blob name cannot be null or empty" or something similar. Maybe could do the check when creating the instance of BlobClient (I am not sure)?
Environment
Microsoft Visual Studio Professional 2022 (64-bit) - Version 17.3.5
Thank you for your feedback. This has been routed to the support team for assistance.
@seanmcc-msft Are we okay to take the change to throw an error if a user passes a empty or default blob name (or blob container name) when attempting to instantiate a BlobClient
and possibly our other storage clients?
There might not be much we can do if they pass a full Uri
instead, but at least with the constructors that take the parsed out names we can do a check.
@amnguye, I think we are ok with this functionality, let's proceed.
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @xgithubtriage.
Issue Details
Library name and version
Azure.Storage.Blobs 12.14.0
Describe the bug
I created a BlobClient
by constructor BlobClient(string connectionString, string blobContainerName, string blobName)
with parameter blobName
set to an empty string.
When I call UploadAsync(BinaryData content)
, it shows the error message "The specified container does not exist". But I did have the container created.
Expected behavior
I think the error message should indicate the blob name cannot be null or empty.
Actual behavior
Azure.RequestFailedException: The specified container does not exist.
RequestId:aa50a74f-901e-003c-3647-e776e0000000
Time:2022-10-24T01:23:27.7599225Z
Status: 404 (The specified container does not exist.)
ErrorCode: ContainerNotFound
Content:
<?xml version="1.0" encoding="utf-8"?><Error><Code>ContainerNotFound</Code><Message>The specified container does not exist.
RequestId:aa50a74f-901e-003c-3647-e776e0000000
Time:2022-10-24T01:23:27.7599225Z</Message></Error>
Headers:
Server: Windows-Azure-Blob/1.0,Microsoft-HTTPAPI/2.0
x-ms-request-id: aa50a74f-901e-003c-3647-e776e0000000
x-ms-client-request-id: 89117e0d-204d-4525-a842-8ef0485e58f7
x-ms-version: 2021-10-04
x-ms-error-code: ContainerNotFound
Date: Mon, 24 Oct 2022 01:23:26 GMT
Content-Length: 225
Content-Type: application/xml
Reproduction Steps
Code to reproduce:
var connectingString = // Storage account connection string.
var blobContainerName = // Blob container name.
var blobName = "";
var filePath = // A file path.
var blobClient = new BlobClient(connectingString , blobContainerName, blobName);
var bytes = System.IO.File.ReadAllBytes(filePath);
await blobClient.UploadAsync(new System.BinaryData(bytes));
In the above code, I set the blobName
to an Empty string. I did have a blobContainerName created already. It returns error:
Azure.RequestFailedException: The specified container does not exist.
RequestId:aa50a74f-901e-003c-3647-e776e0000000
Time:2022-10-24T01:23:27.7599225Z
Status: 404 (The specified container does not exist.)
ErrorCode: ContainerNotFound
Content:
<?xml version="1.0" encoding="utf-8"?><Error><Code>ContainerNotFound</Code><Message>The specified container does not exist.
RequestId:aa50a74f-901e-003c-3647-e776e0000000
Time:2022-10-24T01:23:27.7599225Z</Message></Error>
Headers:
Server: Windows-Azure-Blob/1.0,Microsoft-HTTPAPI/2.0
x-ms-request-id: aa50a74f-901e-003c-3647-e776e0000000
x-ms-client-request-id: 89117e0d-204d-4525-a842-8ef0485e58f7
x-ms-version: 2021-10-04
x-ms-error-code: ContainerNotFound
Date: Mon, 24 Oct 2022 01:23:26 GMT
Content-Length: 225
Content-Type: application/xml
I think the error message can be improved to maybe "The specified blob name cannot be null or empty" or something similar. Maybe could do the check when creating the instance of BlobClient (I am not sure)?
Environment
Microsoft Visual Studio Professional 2022 (64-bit) - Version 17.3.5
Author: | Owenll66 |
---|---|
Assignees: | - |
Labels: |
|
Milestone: | - |
I had the same issue today. The error "The specified container does not exist." still remains confusing. The container is available, but my filename was an empty string.