Repository navigation
Reject blob Acquire Lease without x-ms-lease-duration - #2864
Open
Joel Town Road (hippi345) wants to merge 2 commits into
Open
Joel Town Road (hippi345) wants to merge 2 commits into
Joel Town Road (hippi345) wants to merge 2 commits into
Conversation
Acquire without the required lease duration header was accepted as 201 and left the blob in a state that 500'd on later GET or list. Reject the request with 400 MissingRequiredHeader to match Azure Storage.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The regression test must preserve HTTPS for live-Azure endpoints to avoid failures and plaintext SAS transmission.
1 open issue
What changed in this PR
Fixes #2855 by rejecting blob lease acquisition without a duration before it can corrupt lease state.
Changes:
- Return Azure-compatible
400 MissingRequiredHeaderresponses. - Add regression coverage for rejection and subsequent properties/list requests.
- Document the fix in the changelog.
| File | Description |
|---|---|
| tests/blob/apis/blob.test.ts | Adds missing-duration regression coverage. |
| src/blob/handlers/BlobHandler.ts | Rejects missing duration before updating storage. |
| src/blob/errors/StorageErrorFactory.ts | Adds the required-header error response. |
| ChangeLog.md | Documents the lease validation fix. |
Review effort: Balanced
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.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.

Problem
Acquire Lease without
x-ms-lease-durationwas accepted with 201, then later GET or list of that blob/container returned 500 (LeaseExpiredState:constructor() error, incoming leaseDurationSeconds undefined).Fixes #2855
Azure Storage requires the header on acquire (API version 2012-02-12 and later) and returns 400
MissingRequiredHeader:Lease Blobto acquire a lease now must include a lease duration header. If you try to acquire a lease without specifying a lease duration, the service returns400 Bad Request – Missing required header.”MissingRequiredHeader, HTTP 400, user message “A required HTTP header wasn't specified.”Fix
BlobHandler.acquireLeasenow rejects a missingoptions.durationwithStorageErrorFactory.getMissingRequiredHeader(400,MissingRequiredHeader, Azure’s documented message, andHeaderNamex-ms-lease-duration). The blob is left unchanged so later GET/list succeed.Testing
New test in
tests/blob/apis/blob.test.ts: acquire withoutx-ms-lease-durationvia raw HTTP, assert 400 /MissingRequiredHeader/ documented message /HeaderName, then GET properties and list blobs.Before (unmodified upstream main):
After:
Nearby lease tests (
acquireLease|releaseLease|lease blob|Leaseinblob.test.tsandcontainer.test.ts):This change was prepared with AI assistance. I remain responsible for the contribution and have reviewed it.