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 @@ -13,6 +13,7 @@ General:

Blob:

- Fixed Blob GET and HEAD requests for nonexistent blobs with `If-Match` so they now return `BlobNotFound` instead of `ConditionNotMet`, matching Azure Storage. (issue #2751)
- Fixed block blob uploads with `If-None-Match: *` returning `BlobAlreadyExists` before validating an active lease, matching Azure Storage's `LeaseIdMissing` and lease mismatch error precedence. (issue #2637)
- Fixed service- and container-level Filter Blobs requests failing when the optional `where` query parameter is omitted.
- Fixed blob operations hanging when a client disconnects before the operation queue processes the request. (issue #2575)
Expand Down
8 changes: 4 additions & 4 deletions src/blob/persistence/LokiBlobMetadataStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1206,12 +1206,12 @@ export default class LokiBlobMetadataStore
true
);

validateReadConditions(context, modifiedAccessConditions, doc);

if (!doc) {
throw StorageErrorFactory.getBlobNotFound(context.contextId);
}

validateReadConditions(context, modifiedAccessConditions, doc);

new BlobReadLeaseValidator(leaseAccessConditions).validate(
new BlobLeaseAdapter(doc),
context
Expand Down Expand Up @@ -1289,13 +1289,13 @@ export default class LokiBlobMetadataStore
true
);

validateReadConditions(context, modifiedAccessConditions, doc);

// When block blob don't have committed block, should return 404
if (!doc) {
throw StorageErrorFactory.getBlobNotFound(context.contextId);
}

validateReadConditions(context, modifiedAccessConditions, doc);

new BlobReadLeaseValidator(leaseAccessConditions).validate(
new BlobLeaseAdapter(doc),
context
Expand Down
20 changes: 4 additions & 16 deletions src/blob/persistence/SqlBlobMetadataStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1188,14 +1188,6 @@ export default class SqlBlobMetadataStore implements IBlobMetadataStore {
transaction: t
});

validateReadConditions(
context,
modifiedAccessConditions,
blobFindResult
? this.convertDbModelToBlobModel(blobFindResult)
: undefined
);

if (blobFindResult === null || blobFindResult === undefined) {
throw StorageErrorFactory.getBlobNotFound(context.contextId);
}
Expand All @@ -1204,6 +1196,8 @@ export default class SqlBlobMetadataStore implements IBlobMetadataStore {
blobFindResult
);

validateReadConditions(context, modifiedAccessConditions, blobModel);

return LeaseFactory.createLeaseState(
new BlobLeaseAdapter(blobModel),
context
Expand Down Expand Up @@ -1790,14 +1784,6 @@ export default class SqlBlobMetadataStore implements IBlobMetadataStore {
transaction: t
});

validateReadConditions(
context,
modifiedAccessConditions,
blobFindResult
? this.convertDbModelToBlobModel(blobFindResult)
: undefined
);

if (blobFindResult === null || blobFindResult === undefined) {
throw StorageErrorFactory.getBlobNotFound(context.contextId);
}
Expand All @@ -1810,6 +1796,8 @@ export default class SqlBlobMetadataStore implements IBlobMetadataStore {
throw StorageErrorFactory.getBlobNotFound(context.contextId);
}

validateReadConditions(context, modifiedAccessConditions, blobModel);

// TODO: Return blobCommittedBlockCount for append blob

let responds = LeaseFactory.createLeaseState(
Expand Down
40 changes: 40 additions & 0 deletions tests/blob/apis/blob.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,46 @@ describe("BlobAPIs", () => {
assert.fail();
});

it("download should return BlobNotFound for nonexistent blob with ifMatch @loki @sql", async () => {
const properties = await blobClient.getProperties();
const nonExistentBlobClient = containerClient.getBlobClient(
getUniqueName("missingblob")
);

try {
await nonExistentBlobClient.download(0, undefined, {
conditions: {
ifMatch: properties.etag
}
});
} catch (error) {
assert.deepStrictEqual((error as any).statusCode, 404);
assert.deepStrictEqual((error as any).details.errorCode, "BlobNotFound");
return;
}
assert.fail();
});

it("getProperties should return BlobNotFound for nonexistent blob with ifMatch @loki @sql", async () => {
const properties = await blobClient.getProperties();
const nonExistentBlobClient = containerClient.getBlobClient(
getUniqueName("missingblob")
);

try {
await nonExistentBlobClient.getProperties({
conditions: {
ifMatch: properties.etag
}
});
} catch (error) {
assert.deepStrictEqual((error as any).statusCode, 404);
assert.deepStrictEqual((error as any).details.errorCode, "BlobNotFound");
return;
}
assert.fail();
});

it("download should not work with conditional header ifNoneMatch @loki @sql", async () => {
const properties = await blobClient.getProperties();
try {
Expand Down
Loading