Azure / Azure/Azurite

Inconsistent error status code in Azurite and Azure when use the method beginCopyFromURL on block blob

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

Description

**Error Description:**
IfModifiedSince specify this conditional header to copy the blob from url only if the destination blob has been modified since the specified date/time. If the destination blob has not been modified, the Azure returns status code 412 (Precondition Failed).
But in Azurite, it returns status code 304.
In azure, the error is shown as following:
![Screenshot 2020-11-19 152239](https://user-images.githubusercontent.com/20970631/100181287-d8517300-2f14-11eb-9cb5-84380847e95e.png)
In azurite, the error is shown as following:
![Screenshot 2020-11-19 152155](https://user-images.githubusercontent.com/20970631/100181299-de475400-2f14-11eb-911e-ccc3849f08a1.png)

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

async function main() {
const blobServiceClient = await BlobServiceClient.fromConnectionString("Azurite-https-connectionString");
const containerClient = await blobServiceClient.getContainerClient("");
const originBlobClient = await containerClient.getBlockBlobClient("");
const newBlobClient = await containerClient.getBlockBlobClient("");

try{
await newBlobClient.beginCopyFromURL(originBlobClient.url,{sourceConditions:{
ifModifiedSince:new Date()
}})
}catch(e){
console.log((err as any).response.status);
assert.ok((err as any).response.status === "412");
}
}

main();
```

**Error Track**
When use the method beginCopyFromURL on block blob in azurite, the process code and return error code for the ifModifiedSince are shown as following:
[https://github.com/Azure/Azurite/blob/master/src/blob/conditions/ReadConditionalHeadersValidator.ts#L90](https://github.com/Azure/Azurite/blob/master/src/blob/conditions/ReadConditionalHeadersValidator.ts#L90)
[https://github.com/Azure/Azurite/blob/master/src/blob/conditions/ReadConditionalHeadersValidator.ts#L107](https://github.com/Azure/Azurite/blob/master/src/blob/conditions/ReadConditionalHeadersValidator.ts#L107)
![Screenshot 2020-11-18 163331](https://user-images.githubusercontent.com/20970631/99505454-d25f0d80-29bb-11eb-9898-a803d6a0c46e.png)

**Expected Behavior**
If the destination blob has not been modified in the date time specified by the ifModifiedSince, the error returned in Azurite is consistent with the one in Azure.

@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.