From 7d56f83a83230d39b45b605d7d3b7ce40bfcb13e Mon Sep 17 00:00:00 2001 From: "Jason Cheung (INTUNE)" Date: Mon, 22 Dec 2025 19:12:12 -0800 Subject: [PATCH 1/2] Fix * IfMatch for non-existent resource not throwing 412 Precondition Failed --- .../WriteConditionalHeadersValidator.ts | 6 ++-- tests/blob/conditions.test.ts | 32 +++++++++++++++++++ 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/blob/conditions/WriteConditionalHeadersValidator.ts b/src/blob/conditions/WriteConditionalHeadersValidator.ts index 88ca42dd8..b4f34134c 100644 --- a/src/blob/conditions/WriteConditionalHeadersValidator.ts +++ b/src/blob/conditions/WriteConditionalHeadersValidator.ts @@ -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 + throw StorageErrorFactory.getConditionNotMet(context.contextId!); } if (conditionalHeaders.ifModifiedSince) { diff --git a/tests/blob/conditions.test.ts b/tests/blob/conditions.test.ts index 852c6afa1..e32769808 100644 --- a/tests/blob/conditions.test.ts +++ b/tests/blob/conditions.test.ts @@ -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", () => { From 7a059ae9e695798b86af69118be30ae31fad675f Mon Sep 17 00:00:00 2001 From: "Jason Cheung (INTUNE)" Date: Mon, 22 Dec 2025 19:16:59 -0800 Subject: [PATCH 2/2] Update ChangeLog.md --- ChangeLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog.md b/ChangeLog.md index c29751d9c..51cd48fd2 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -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