Azure / Azure/Azurite

It doesn't return an error when upload block blob with wrong blobContentMD5 in Azurite

Open
#822 8 comments 0 reactions 1 assignee Claimed by @blueww View on GitHub
alignment blob-storage stale
Dominant language
TypeScript
Stars
2.3k
Forks
393
Avg merge
1d 20h
Merged PRs (30d)
36

Description

**Error Description:**
In Azure, it will return an error `Md5Mismatch` if the uploaded md5 value is wrong when upload block blob.
But in Azurite. it will upload block blob successfully.
Azure error is shown as following:
![Screenshot 2021-06-08 185933](https://user-images.githubusercontent.com/20970631/121174354-6a571280-c88c-11eb-96e5-6ce59c6af083.png)

**To Reproduce:**
Please run the demo code as following:
```Typescript
import { BlobServiceClient, StorageSharedKeyCredential } from "@azure/storage-blob";
import * as crypto from "crypto";

async function main(){
const blobServiceClient= new BlobServiceClient("",new StorageSharedKeyCredential("",""));
const containerClient = blobServiceClient.getContainerClient("");
await containerClient.create();
const content = "correct value";
const blockBlobClient = containerClient.getBlockBlobClient("");
const sourceContentMD5 = crypto
.createHash("md5")
.update(Buffer.from("wrong value"))
.digest();
const uploadBlobResponse = await blockBlobClient.upload(content, Buffer.byteLength(content),{blobHTTPHeaders:{blobContentMD5:sourceContentMD5}});
console.log(`Upload block blob ${blobName} successfully`, uploadBlobResponse.requestId);
}

main().catch((err)=>{
console.log(err);
});
```

**Error Track:**
The process code of md5 is shown as following:
[https://github.com/Azure/Azurite/blob/master/src/blob/handlers/BlockBlobHandler.ts#L46](https://github.com/Azure/Azurite/blob/master/src/blob/handlers/BlockBlobHandler.ts#L46)
![image](https://user-images.githubusercontent.com/20970631/121175502-b191d300-c88d-11eb-831c-7b14ac92ceb4.png)
![image](https://user-images.githubusercontent.com/20970631/121175873-25cc7680-c88e-11eb-9dac-0c3a4fcb46ff.png)
The request doesn't contain `content-md5` when upload a block blob via put blob API.
So as shown, it doesn't use uploaded md5 value to be compared with the md5 value calculated by the server and not return any error.

**Expected Behavior:**
It should return an error `Md5Mismatch` when uploaded md5 value is wrong.

@jongio for notification.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.