Azure / Azurite

A lightweight server clone of Azure Storage that simulates most of the commands supported by it with minimal dependencies
MIT License
1.83k stars 325 forks source link

Invalid inferred status for block blob which uploaded by PutBlob command #2038

Closed zhaldak closed 1 year ago

zhaldak commented 1 year ago

Which service(blob, file, queue, table) does this issue concern?

blob service

Which version of the Azurite was used?

3.24.0

Where do you get Azurite? (npm, DockerHub, NuGet, Visual Studio Code Extension)

npm

What's the Node.js version?

v19.8.1

What problem was encountered?

When block blob is uploaded by one PutBlob command with explicitly set access tier the blob is marked as "inferred".

Steps to reproduce the issue?

Send Put Blob command with x-ms-access-tier: Hot. Or a small file (less then 1KiB) can be uploaded via MS Azure Storage Explorer (a version is not matter) as Block Blob with "Target Access Tier: Hot".

Have you found a mitigation/solution?

The solution is just to add the line to "src/blob/handlers/BlockBlobHandler.ts" into BlockBlobHandler::upload:

129    if (options.tier !== undefined) {
130      blob.properties.accessTier = this.parseTier(options.tier);
131      if (blob.properties.accessTier === undefined) {
132        throw StorageErrorFactory.getInvalidHeaderValue(context.contextId, {
133          HeaderName: "x-ms-access-tier",
134          HeaderValue: `${options.tier}`
135        });
136      }
   +     blob.properties.accessTierInferred = false
137    }

I sorry that it is not a PR.

blueww commented 1 year ago

@zhaldak Thanks for raising this issue! Will look into how to fix it. (we might also need to fix other API like set access tier.)

Azurite welcome contribution! It would be great if you can raise a PR to fix it!