Azurite icon indicating copy to clipboard operation
Azurite copied to clipboard

BlockBlob_StageBlock: upload a block with zero bytes should fail

Open blueww opened this issue 6 years ago • 2 comments

Which service(blob, file, queue, table) does this issue concern?

blob

Which version of the Azurite was used?

3.3.0-preview

Where do you get Azurite? (npm, DockerHub, NuGet, Visual Studio Code Extension)

VS code

What's the Node.js version?

v10.15.3

What problem was encountered?

BlockBlob_StageBlock: upload a block with zero bytes should fail with 400, but now not fail.

Steps to reproduce the issue?

byte[] buffer = new byte[0];
                using (MemoryStream stream = new MemoryStream(buffer))
                {
                    TestHelper.ExpectedException(
                        () => blob.PutBlock(blockId, stream, null),
                        "Trying to upload a block with zero bytes should fail",
                        HttpStatusCode.BadRequest);
                }

Have you found a mitigation/solution?

No Debug log:

2019-12-18T02:27:29.835Z 748c493f-aba2-4e6c-b848-466dc2144a7e info: BlobStorageContextMiddleware: RequestMethod=PUT RequestURL=http://127.0.0.1/devstoreaccount1/testca66a4be699c84b74829b9451201690c8/blob1?comp=block&blockid=E5WzLPi1x0uWYIdjzFeWeQ%3D%3D RequestHeaders:{"x-ms-client-request-id":"3f4a2f3f-eebf-46c3-9535-69b6c64ae2c8","user-agent":"Azure-Storage/11.1.1 (.NET Core; Win32NT 6.2.9200.0)","x-ms-version":"2019-02-02","x-ms-date":"Wed, 18 Dec 2019 02:27:29 GMT","authorization":"SharedKey devstoreaccount1:K98vLUjpCbOrhAnaiT+rj3Nfd6otnJGnCkTyDQEICJg=","content-length":"0","host":"127.0.0.1:10000"} ClientIP=127.0.0.1 Protocol=http HTTPVersion=1.1
2019-12-18T02:27:29.835Z 748c493f-aba2-4e6c-b848-466dc2144a7e info: BlobStorageContextMiddleware: Account=devstoreaccount1 Container=testca66a4be699c84b74829b9451201690c8 Blob=blob1
2019-12-18T02:27:29.835Z 748c493f-aba2-4e6c-b848-466dc2144a7e verbose: DispatchMiddleware: Dispatching request...
2019-12-18T02:27:29.836Z 748c493f-aba2-4e6c-b848-466dc2144a7e info: DispatchMiddleware: Operation=BlockBlob_StageBlock
2019-12-18T02:27:29.837Z 748c493f-aba2-4e6c-b848-466dc2144a7e verbose: AuthenticationMiddlewareFactory:createAuthenticationMiddleware() Validating authentications.
2019-12-18T02:27:29.837Z 748c493f-aba2-4e6c-b848-466dc2144a7e info: PublicAccessAuthenticator:validate() Start validation against public access.
2019-12-18T02:27:29.837Z 748c493f-aba2-4e6c-b848-466dc2144a7e debug: PublicAccessAuthenticator:validate() Getting account properties...
2019-12-18T02:27:29.838Z 748c493f-aba2-4e6c-b848-466dc2144a7e debug: PublicAccessAuthenticator:validate() Retrieved account name from context: devstoreaccount1, container: testca66a4be699c84b74829b9451201690c8, blob: blob1
2019-12-18T02:27:29.840Z 748c493f-aba2-4e6c-b848-466dc2144a7e debug: PublicAccessAuthenticator:validate() Skip public access authentication. Cannot get public access type for container testca66a4be699c84b74829b9451201690c8
2019-12-18T02:27:29.841Z 748c493f-aba2-4e6c-b848-466dc2144a7e info: BlobSharedKeyAuthenticator:validate() Start validation against account shared key authentication.
2019-12-18T02:27:29.841Z 748c493f-aba2-4e6c-b848-466dc2144a7e info: BlobSharedKeyAuthenticator:validate() [STRING TO SIGN]:"PUT\n\n\n\n\n\n\n\n\n\n\n\nx-ms-client-request-id:3f4a2f3f-eebf-46c3-9535-69b6c64ae2c8\nx-ms-date:Wed, 18 Dec 2019 02:27:29 GMT\nx-ms-version:2019-02-02\n/devstoreaccount1/devstoreaccount1/testca66a4be699c84b74829b9451201690c8/blob1\nblockid:E5WzLPi1x0uWYIdjzFeWeQ==\ncomp:block"
2019-12-18T02:27:29.842Z 748c493f-aba2-4e6c-b848-466dc2144a7e info: BlobSharedKeyAuthenticator:validate() Calculated authentication header based on key1: SharedKey devstoreaccount1:K98vLUjpCbOrhAnaiT+rj3Nfd6otnJGnCkTyDQEICJg=
2019-12-18T02:27:29.842Z 748c493f-aba2-4e6c-b848-466dc2144a7e info: BlobSharedKeyAuthenticator:validate() Signature 1 matched.
2019-12-18T02:27:29.842Z 748c493f-aba2-4e6c-b848-466dc2144a7e verbose: DeserializerMiddleware: Start deserializing...
2019-12-18T02:27:29.842Z 748c493f-aba2-4e6c-b848-466dc2144a7e info: HandlerMiddleware: DeserializedParameters={"blockId":"E5WzLPi1x0uWYIdjzFeWeQ==","options":{"requestId":"3f4a2f3f-eebf-46c3-9535-69b6c64ae2c8","leaseAccessConditions":{},"cpkInfo":{}},"comp":"block","contentLength":0,"version":"2019-02-02","body":"ReadableStream"}
2019-12-18T02:27:29.844Z 748c493f-aba2-4e6c-b848-466dc2144a7e debug: OperationQueue.operate() Schedule incoming job e7f92a30-ce77-4cde-9c19-ff754f0a5851
2019-12-18T02:27:29.845Z 748c493f-aba2-4e6c-b848-466dc2144a7e debug: OperationQueue:execute() Current runningConcurrency:0 maxConcurrency:10 operations.length:1
2019-12-18T02:27:29.845Z 748c493f-aba2-4e6c-b848-466dc2144a7e info: FSExtentStore:appendExtent() Select extent from idle location for extent append operation. LocationId:1 extentId:c97d0867-024c-4085-bf44-9f13d85d96b4 offset:2096128 MAX_EXTENT_SIZE:4194304 
2019-12-18T02:27:29.845Z 748c493f-aba2-4e6c-b848-466dc2144a7e debug: FSExtentStore:appendExtent() Get fd:44 for extent:c97d0867-024c-4085-bf44-9f13d85d96b4 from cache.
2019-12-18T02:27:29.846Z 748c493f-aba2-4e6c-b848-466dc2144a7e debug: FSExtentStore:appendExtent() Start writing to extent c97d0867-024c-4085-bf44-9f13d85d96b4
2019-12-18T02:27:29.846Z 748c493f-aba2-4e6c-b848-466dc2144a7e debug: FSExtentStore:appendExtent() Write finish, start updating extent metadata. extent:{"id":"c97d0867-024c-4085-bf44-9f13d85d96b4","persistencyId":"Default","path":"c97d0867-024c-4085-bf44-9f13d85d96b4","size":2096128,"lastModifiedInMS":1576636049846}
2019-12-18T02:27:29.847Z 748c493f-aba2-4e6c-b848-466dc2144a7e debug: FSExtentStore:appendExtent() Update extent metadata done. Resolve()
2019-12-18T02:27:29.847Z 748c493f-aba2-4e6c-b848-466dc2144a7e debug: OperationQueue.operate() Job e7f92a30-ce77-4cde-9c19-ff754f0a5851 completes callback, resolve.
2019-12-18T02:27:29.849Z 748c493f-aba2-4e6c-b848-466dc2144a7e verbose: SerializerMiddleware: Start serializing...
2019-12-18T02:27:29.849Z 748c493f-aba2-4e6c-b848-466dc2144a7e info: EndMiddleware: End response. TotalTimeInMS=14 StatusCode=201 StatusMessage=undefined Headers={"server":"Azurite-Blob/3.3.0-preview","x-ms-client-request-id":"3f4a2f3f-eebf-46c3-9535-69b6c64ae2c8","x-ms-request-id":"748c493f-aba2-4e6c-b848-466dc2144a7e","x-ms-version":"2019-02-02","date":"Wed, 18 Dec 2019 02:27:29 GMT","x-ms-request-server-encrypted":"true"}
2019-12-18T02:27:29.850Z 748c493f-aba2-4e6c-b848-466dc2144a7e debug: OperationQueue:execute() Current runningConcurrency:0 maxConcurrency:10 operations.length:0
2019-12-18T02:27:29.850Z 748c493f-aba2-4e6c-b848-466dc2144a7e debug: OperationQueue:execute() return. Operation.length === 0

Test Case:

Test Name:	CloudBlockBlobPutBlockBoundaries
Test FullName:	Microsoft.Azure.Storage.Blob.CloudBlockBlobTest.CloudBlockBlobPutBlockBoundaries
Test Source:	C:\code\azure-storage-net\Test\ClassLibraryCommon\Blob\CloudBlockBlobTest.cs : line 4150
Test Outcome:	Failed
Test Duration:	0:00:00.2631287

Result StackTrace:	
at Microsoft.Azure.Storage.TestHelper.ExpectedException(Action operation, String operationDescription, HttpStatusCode expectedStatusCode, String requestErrorCode) in C:\code\azure-storage-net\Test\ClassLibraryCommon\TestHelper.cs:line 55
   at Microsoft.Azure.Storage.Blob.CloudBlockBlobTest.CloudBlockBlobPutBlockBoundaries() in C:\code\azure-storage-net\Test\ClassLibraryCommon\Blob\CloudBlockBlobTest.cs:line 4163
Result Message:	Assert.Fail failed. No Storage exception received while expecting BadRequest: Trying to upload a block with zero bytes should fail

blueww avatar Dec 18 '19 02:12 blueww

Negative undocumented behavior, post ga item.

https://docs.microsoft.com/en-us/rest/api/storageservices/put-block

XiaoningLiu avatar Dec 25 '19 03:12 XiaoningLiu

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 16 '22 12:04 stale[bot]