BlobLeaseClient.GetBlobClient returns "The value for one of the HTTP headers is not in the correct format" exception
See original GitHub issueDescribe the bug When trying to aquire a lease on a blob I get the an exception.
Expected behavior I should be able to acquire a lease on this blob.
Actual behavior (include Exception or Stack Trace)
The value for one of the HTTP headers is not in the correct format.
RequestId:<guid>
Time:2020-09-30T10:28:47.8781946Z
Status: 400 (The value for one of the HTTP headers is not in the correct format.)
ErrorCode: InvalidHeaderValue
Headers:
Server: Windows-Azure-Blob/1.0,Microsoft-HTTPAPI/2.0
x-ms-request-id: <guid>
x-ms-client-request-id: <guid>
x-ms-version: 2019-12-12
x-ms-error-code: InvalidHeaderValue
Date: Wed, 30 Sep 2020 10:28:47 GMT
Content-Length: 328
Content-Type: application/xml
To Reproduce
BlockBlobClient blockBlobClient = new BlockBlobClient(
"connectionstring",
"containername",
"blob");
BlobLeaseClient blc = blockBlobClient.GetBlobLeaseClient();
//exception here
BlobLease bl = await blc.AcquireAsync(new TimeSpan(0, 0, 10));
Environment:
- Azure.Storage.Blobs, Version=12.6.0.0
Issue Analytics
- State:
- Created 3 years ago
- Comments:15 (9 by maintainers)
Top Results From Across the Web
c# - BlobContainerClient throws "Error: The value for one of ...
CreateIfNotExists throws an error saying The value for one of the HTTP headers is not in the correct format. The above error occurs...
Read more >Error: The value for one of the HTTP headers is not in ...
I am uploading files from Expressjs into a file storage, when I try to access uploaded file I get an error "The value...
Read more >@azure/storage-blob - Microsoft .NET
Indicates the version of the Blob service used to execute the request. This header is returned for requests made against version 2009-09-19 and...
Read more >Module: Azure::Storage::Blob::Container
Proposed lease ID, in a GUID string format. The Blob service returns 400 (Invalid request) if the proposed lease ID is not in...
Read more >BlobContainerClient - azure-storage-blob 12.23.0 javadoc
Creates a new container within a storage account if it does not exist. ... Returns a lazy loaded list of blobs in this...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Client-side validation can result in really painful forward compatibility problems.
To better illustrate, let’s pretend we added client-side validation for an operation like Set Blob Tags. There’s a maximum of 10 tags so why not enforce that before we send an expensive request across the network? It seems safe.
It’s harder to imagine something like this happening with blob leases, but I could see someone getting the current lease duration via
GetProperties
and callingLeaseClient.Break
with it (i.e., I’ll let you finish one lease, but not renew it).If we can’t make the error messages better with #14469, then the most we should do is post facto client-side validation where we catch the error, determine it’s because the lease was out of range, and then wrap it in an exception that’s more helpful to customers.
Hi,
“A non-infinite lease can be between 15 and 60 seconds”. https://docs.microsoft.com/en-us/rest/api/storageservices/lease-blob (see x-ms-lease-duration)
That’s why the stackoverflow link you used worked cause it was 30 seconds while the snippet you provided was 10 seconds. So the error code you got back from the service “InvalidHeaderValue” is correct.