No checksum validation error on blob upload
- Dominant language
- TypeScript
- Stars
- 2.3k
- Forks
- 393
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 36
Description
### Which service(blob, file, queue, table) does this issue concern?
Blob
### Which version of the Azurite was used?
latest and 3.16.0
### Where do you get Azurite? (npm, DockerHub, NuGet, Visual Studio Code Extension)
Dockerhub
### What's the Node.js version?
See docker image
### What problem was encountered?
When uploading a blob and passing locally calculated MD5 hash, the API should throw an error. Azure Storage Emulator returns the expected HTTP error, Azureite returns no error (but calculates the correct hash).
It is not a huge thing, but conflicts with this:
> Azurite tries to align with Azure Storage error handling logic, and provides best-efforts alignment based on Azure Storage online documentation. But CANNOT provide 100% alignment, such as error messages (returned in error response body) maybe different (while error status code will align).
### Steps to reproduce the issue?
Using nuget *Azure.Storage.Blobs*
```csharp
string _ConnectionString = "UseDevelopmentStorage=true";
BlobServiceClient _blobClient = new BlobServiceClient(_ConnectionString);
using var stream = new MemoryStream(new byte[] { 0, 1, 0, 1, 0, 1 });
var container = _blobClient.GetBlobContainerClient("test");
await container.CreateIfNotExistsAsync();
var blockBlob = container.GetBlockBlobClient("myfile");
try
{
var x = await blockBlob.UploadAsync(stream,
new BlobUploadOptions
{
HttpHeaders = new BlobHttpHeaders
{
//ContentHash = Convert.FromBase64String("9V+R+Ra60Erbh/oKA1AA+g==") // Correct
ContentHash = Convert.FromBase64String("0V+R+Ra60Erbh/oKA1AA+g==") // Incorrect
}
}).ConfigureAwait(false);
}
catch (RequestFailedException ex) when (ex.Status == 400 && ex.ErrorCode == BlobErrorCode.Md5Mismatch)
{
// Azureite does not throw here, storage emulator does
throw new Exception("The checksum of the uploaded file does not match the checksum of the request");
}
var blob = container.GetBlockBlobClient("myfile");
var props = blob.GetProperties();
Debug.Assert(props.Value.ContentLength == 6, "blob size should be the same as the input stream");
Console.WriteLine("Saved MD5 value: " + Convert.ToBase64String(props.Value.ContentHash));
```
### Have you found a mitigation/solution?
-
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.