Validate copy sources with HEAD instead of downloading the blob - #2680
Open
gaul wants to merge 2 commits into
Open
Validate copy sources with HEAD instead of downloading the blob#2680gaul wants to merge 2 commits into
gaul wants to merge 2 commits into
Conversation
startCopyFromURL and copyFromURL validate the copy source by fetching <source>?comp=metadata through axios. Azurite serves that request as a full Blob_Download (issue Azure#646), so every validated copy downloaded the entire source only to discard it, and a source blob declaring Content-Encoding: gzip over bytes that are not really gzip made axios decompression fail and turned every copy of that blob into a 500. Validate with a bodiless HEAD (Get Blob Properties) request instead. Error details live only in response bodies, and reading an archived source must fail the copy like the download did, so those cases repeat the request as the previous comp=metadata GET, now with axios decompression disabled. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR optimizes blob copy-source validation in Azurite by switching from a metadata GET (which Azurite currently serves as a full blob download) to a bodiless HEAD request, avoiding unnecessary data transfer and preventing axios decompression failures when the source declares Content-Encoding: gzip over non-gzip bytes.
Changes:
- Update copy-source validation to use
HEAD(Get Blob Properties) and retry withGET ?comp=metadataonly when needed, with axios decompression disabled on the retry. - Add a SAS-based regression test ensuring copy succeeds when the source declares
Content-Encoding: gzipbut the payload is not gzipped. - Document the behavior change in
ChangeLog.md.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/blob/sas.test.ts | Adds regression coverage for copy with misleading Content-Encoding: gzip on the source blob. |
| src/blob/handlers/BlobHandler.ts | Switches copy-source validation to HEAD, with a conditional GET ?comp=metadata retry to preserve error details and avoid decompression issues. |
| ChangeLog.md | Notes the optimization/fix in the upcoming release section. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+601
to
+603
| await blob2.beginCopyFromURL(blob1.url); | ||
|
|
||
| const properties = await blob2.getProperties(); |
beginCopyFromURL resolves once the poller is created, not when the copy finishes, so poll to completion like the neighboring tests. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
startCopyFromURL and copyFromURL validate the copy source by fetching?comp=metadata through axios. Azurite serves that request as a full Blob_Download (issue #646), so every validated copy downloaded the entire source only to discard it, and a source blob declaring Content-Encoding: gzip over bytes that are not really gzip made axios decompression fail and turned every copy of that blob into a 500.
Validate with a bodiless HEAD (Get Blob Properties) request instead. Error details live only in response bodies, and reading an archived source must fail the copy like the download did, so those cases repeat the request as the previous comp=metadata GET, now with axios decompression disabled.