Skip to content

Validate copy sources with HEAD instead of downloading the blob - #2680

Open
gaul wants to merge 2 commits into
Azure:mainfrom
gaul:fix-copy-gzip-source
Open

Validate copy sources with HEAD instead of downloading the blob#2680
gaul wants to merge 2 commits into
Azure:mainfrom
gaul:fix-copy-gzip-source

Conversation

@gaul

@gaul gaul commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

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.

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>
Copilot AI review requested due to automatic review settings July 24, 2026 00:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 with GET ?comp=metadata only when needed, with axios decompression disabled on the retry.
  • Add a SAS-based regression test ensuring copy succeeds when the source declares Content-Encoding: gzip but 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 thread tests/blob/sas.test.ts Outdated
Comment on lines +601 to +603
await blob2.beginCopyFromURL(blob1.url);

const properties = await blob2.getProperties();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

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>
Copilot AI review requested due to automatic review settings July 24, 2026 00:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants