Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ General:

- Performance improvements for internal metadata access using in-memory metadata store
- Fix building failure on Node 22 platform.
- Fix * IfMatch for non-existent resource not throwing 412 Precondition Failed

## 2025.07 Version 3.35.0

Expand Down
6 changes: 2 additions & 4 deletions src/blob/conditions/WriteConditionalHeadersValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,8 @@ export default class WriteConditionalHeadersValidator
if (conditionalHeaders.ifMatch && conditionalHeaders.ifMatch.length > 0) {
// If a request specifies both the If-Match and If-Unmodified-Since headers,
// the request is evaluated based on the criteria specified in If-Match.
if (conditionalHeaders.ifMatch[0] !== "*") {
throw StorageErrorFactory.getConditionNotMet(context.contextId!);
}
return;
// Throw if there is any value in if-match for non exist blob
Copy link
Member

@blueww blueww Jan 6, 2026

Choose a reason for hiding this comment

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

Could you validate all the write request call this function on real azure server will have this behavior?
If so, this change is OK.
Else, you might need to so some check for the API here.

Others are all good for me.

throw StorageErrorFactory.getConditionNotMet(context.contextId!);
}

if (conditionalHeaders.ifModifiedSince) {
Expand Down
32 changes: 32 additions & 0 deletions tests/blob/conditions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,38 @@ describe("WriteConditionalHeadersValidator for nonexistent resource", () => {

assert.fail();
});

it("Should throw 412 Precondition Failed for * if-match @loki @sql", () => {
const validator = new WriteConditionalHeadersValidator();
const modifiedAccessConditions = {
ifMatch: "*"
};

const expectedError = StorageErrorFactory.getConditionNotMet(
context.contextId!
);

try {
validator.validate(
context,
new ConditionalHeadersAdapter(context, modifiedAccessConditions),
new ConditionResourceAdapter(undefined)
);
} catch (error) {
assert.deepStrictEqual(error.statusCode, expectedError.statusCode);
assert.deepStrictEqual(
error.storageErrorCode,
expectedError.storageErrorCode
);
assert.deepStrictEqual(
error.storageErrorMessage,
expectedError.storageErrorMessage
);
return;
}

assert.fail();
});
});

describe("WriteConditionalHeadersValidator for exist resource", () => {
Expand Down
Loading