Azure / Azure/Azurite

Azurite truncates blob if Content-Length: 0 header is added with metadata updates, but Azure blob does not truncate

Open
#1,668 11 comments 0 reactions 1 assignee Claimed by @blueww View on GitHub
blob-storage question
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?
block blob

### Which version of the Azurite was used?
mcr.microsoft.com/azure-storage/azurite

### Where do you get Azurite? (npm, DockerHub, NuGet, Visual Studio Code Extension)
mcr.microsoft.com/azure-storage/azurite

### What's the Node.js version?
N/A

### What problem was encountered?
Blob REST API requires a Content-Length header be provided for metadata updates even though the documentation doesn't mention it:
https://docs.microsoft.com/en-us/rest/api/storageservices/set-blob-metadata
If we provide Content-Length = 0 to blob, the put metadata call succeeds without any issues and the blob shows the new metadata with its contents intact.

With Azurite, the same call with Content-Length = 0, results in the blob getting truncated to 0 length.

Also, note that the Content-Length header is required when sending the request to Azure block blob. However, the Content-Length header can be skipped when sending the request to Azurite. If the Content-Length header is skipped, Azurite correctly updates the metadata without truncating the underlying blob.

### Steps to reproduce the issue?

If possible, please provide the debug log using the -d parameter, replacing \ with an appropriate path for your OS, or review the instructions for docker containers:

```
-d ""
```

Please be sure to remove any PII or sensitive information before sharing!
The debug log will log raw request headers and bodies, so that we can replay these against Azurite using REST and create tests to validate resolution.

### Have you found a mitigation/solution?

The current mitigation is to skip the Content-Length header when sending the request to Azurite, but providing the header with 0 value when talking to blob.

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.