Skip to content

Reject Put Blob requests that target a snapshot URL - #2863

Open
Joel Town Road (hippi345) wants to merge 1 commit into
Azure:mainfrom
hippi345:fix/2854-reject-put-to-snapshot
Open

Joel Town Road (hippi345) wants to merge 1 commit into
Azure:mainfrom
hippi345:fix/2854-reject-put-to-snapshot

Conversation

@hippi345

Copy link
Copy Markdown

Problem

Put Blob sent to a blob URL that includes ?snapshot= was applied to the base blob. A snapshot write returned 201, after which GET on the base blob returned the new body. Snapshots are read-only; Azure Storage rejects this write.

Fixes #2854

Fix

BlockBlobHandler.upload now rejects a non-empty snapshot query parameter before any content is persisted, with:

  • HTTP 400
  • Error code InvalidOperation
  • Message Invalid operation against a blob snapshot.

This matches Blob Storage error codes (InvalidOperation / Bad Request (400) / "Invalid operation against a blob snapshot."), Put Blob (URI parameters list only timeout, not snapshot), and Snapshot Blob remarks (a snapshot is a read-only copy).

Testing

New test in tests/blob/apis/blob.test.ts: Put Blob to a snapshot URL is rejected (400 / InvalidOperation / the Azure message) and the base blob content is unchanged.

Before (unmodified upstream main):

  BlobAPIs
    1) should reject Put Blob to a snapshot URL and leave the base blob unchanged @loki @sql


  0 passing (69ms)
  1 failing

  1) BlobAPIs
       should reject Put Blob to a snapshot URL and leave the base blob unchanged @loki @sql:
     AssertionError [ERR_ASSERTION]: Put Blob to a snapshot URL should be rejected
      at Context.<anonymous> (tests/blob/apis/blob.test.ts:582:12)
      at processTicksAndRejections (node:internal/process/task_queues:105:5)

After (this change):

  BlobAPIs
    ✔ should create a snapshot from a blob @loki @sql
    ✔ should reject Put Blob to a snapshot URL and leave the base blob unchanged @loki @sql
    ✔ Create a snapshot from a blob with ifTags @loki @sql
    ✔ should create a snapshot with metadata from a blob @loki @sql
    ✔ should not delete base blob without include snapshot header @loki @sql
    ✔ should delete snapshot @loki @sql
    ✔ should also list snapshots @loki @sql
    ✔ set/get blob tag should work, with base blob or snapshot @loki @sql

  BlockBlobAPIs
    ✔ getBlockList from snapshot @loki @sql

  AppendBlobAPIs
    ✔ Create append blob snapshot should work @loki
    ✔ Create append blob snapshot and seal should work and copy seal @loki
    ✔ Copy append blob snapshot should work @loki
    ✔ Synchronized copy append blob snapshot should work @loki
    ✔ Download append blob should work for snapshot @loki


  14 passing (313ms)

This change was prepared with AI assistance. I remain responsible for the contribution and have reviewed it.

Put Blob with a snapshot query parameter was applied to the base blob.
Reject it with 400 InvalidOperation, matching Azure Storage.
Copilot AI balanced review requested due to automatic review settings October 17, 2026 01:36

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.

🟢 Approval recommended

The localized guard addresses the reported overwrite with focused regression coverage and no unresolved findings; tests were not rerun.

No open issues 🎉

What changed in this PR

Prevents snapshot-targeted block blob uploads from overwriting the base blob, addressing #2854.

Changes:

  • Rejects non-empty snapshot parameters with 400 InvalidOperation before persistence.
  • Adds regression coverage for the error response and unchanged base content.
  • Documents the fix in the changelog.
File Description
tests/​blob/​apis/​blob.test.ts Tests snapshot upload rejection and base content preservation.
src/​blob/​handlers/​BlockBlobHandler.ts Adds an early snapshot-write rejection guard.
ChangeLog.md Records the snapshot-write fix.

Review effort: Balanced

@hippi345
Joel Town Road (hippi345) marked this pull request as ready for review October 17, 2026 01:47
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.

PUT to a snapshot URL overwrites the base blob

2 participants