azure-sdk-for-js: @azure/storage-blob@>12.2.0 throws `Bad Request - Invalid Verb` on upload

Similar to #11163.

I have script running every 5 minutes for all of eternity that uploads to blob storage, starting ~a day ago I started getting consistent Bad Request - Invalid Verb errors from this code:

	const blobServiceClient = BlobServiceClient.fromConnectionString(key)
	const containerClient = blobServiceClient.getContainerClient(container)

	const createContainerResponse = containerClient.getBlockBlobClient(name)

	await createContainerResponse.uploadStream(Readable.from([text]))

This is consistent with the release of 12.2.0, which I see made some changes to the uploadStream method.

The exact response is as follows:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Bad Request - Invalid Verb</h2>
<hr><p>HTTP Error 400. The request verb is invalid.</p>
</BODY></HTML> 

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 5
  • Comments: 34 (23 by maintainers)

Commits related to this issue

Most upvoted comments

We belive this issue is addressed in the hotfix: @azure/storage-blob@12.2.1 and @azure/storage-file-datalake@12.1.1 Let me know if not.

any workaround we can apply to avoid this temporarily ?

A fix is coming soon. Before that, could you call uploadFile for file, or stageBlock and commitBlockList individually.

      const body = () => yourStream;
      await blockBlobClient.stageBlock(base64encode("1"), body, body.length);
      await blockBlobClient.stageBlock(base64encode("2"), body2, body2.length);
      await blockBlobClient.commitBlockList([base64encode("1"), base64encode("2")]);

Also, disabling keep-alive will also work.

    const pipeline = newPipeline(credential, {
      keepAliveOptions: {
        enable: false
      }
    });

    const blobPrimaryURL = `https://${credential.accountName}${accountNameSuffix}.blob.core.windows.net/`;
    return new BlobServiceClient(blobPrimaryURL, pipeline);

Good news. Successuflly recreated it locally. Will look into the Fiddler tracing.

https://httptoolkit.tech/javascript seems useful for intercepting HTTP(S) traffic. Never used it though.

@ljian3377 , Don’t know if it’s still relevant, but happens for me on Windows. Will attach my logs.

I also ran some other versions, 12.2.0-dev.20200901.1 and 12.2.0-alpha.20200903.1. 12.2.0-dev.20200901.1 worked, but 12.2.0-alpha.20200903.1 did not. I attached logs from 12.2.0 and 12.2.0-dev.20200901.1.

12.2.0

[Node] azure:core-http:info ServiceClient: using custom request policies
[Node] azure:core-http:info ServiceClient: using custom request policies
[Node] azure:core-http:info ServiceClient: using custom request policies
[Node] azure:storage-blob:info RetryPolicy: =====> Try=1 Primary
[Node] azure:storage-blob:info Request: {
[Node]   "streamResponseBody": false,
[Node]   "url": "<redacted>/076998c5-c7e5-4e70-8c34-9d61046b9464.pdf?blockid=YmFlNjdhYmItNGYwNC00NjdmLThlZWItZTcxMzk2Yzc2YWVkMDAwMDAwMDAwMDAw&comp=block",
[Node]   "method": "PUT",
[Node]   "headers": {
[Node]     "_headersMap": {
[Node]       "content-type": "application/octet-stream",
[Node]       "content-length": "42231",
[Node]       "x-ms-version": "2019-12-12",
[Node]       "user-agent": "azsdk-js-storageblob/12.2.0 (NODE-VERSION v12.16.3; Windows_NT 10.0.19042)",
[Node]       "x-ms-client-request-id": "76b2813e-8f88-4227-81c5-5e7e8c930226"
[Node]     }
[Node]   },
[Node]   "withCredentials": false,
[Node]   "timeout": 0,
[Node]   "keepAlive": true,
[Node]   "requestId": "76b2813e-8f88-4227-81c5-5e7e8c930226"
[Node] }
[Node] azure:storage-blob:info Response status code: 201
[Node] azure:storage-blob:info Headers: {
[Node]   "_headersMap": {
[Node]     "content-length": "0",
[Node]     "date": "Sun, 13 Sep 2020 19:25:33 GMT",
[Node]     "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
[Node]     "x-ms-client-request-id": "76b2813e-8f88-4227-81c5-5e7e8c930226",
[Node]     "x-ms-content-crc64": "X181cPKpCPw=",
[Node]     "x-ms-request-id": "d0344ea5-901e-010b-2c03-8a68f7000000",
[Node]     "x-ms-request-server-encrypted": "true",
[Node]     "x-ms-version": "2019-12-12"
[Node]   }
[Node] }
[Node] azure:storage-blob:info RetryPolicy: =====> Try=1 Primary
[Node] azure:storage-blob:info Request: {
[Node]   "streamResponseBody": false,
[Node]   "url": "<redacted>/076998c5-c7e5-4e70-8c34-9d61046b9464.pdf?comp=blocklist",
[Node]   "method": "PUT",
[Node]   "headers": {
[Node]     "_headersMap": {
[Node]       "content-type": "application/xml; charset=utf-8",
[Node]       "x-ms-version": "2019-12-12",
[Node]       "user-agent": "azsdk-js-storageblob/12.2.0 (NODE-VERSION v12.16.3; Windows_NT 10.0.19042)",
[Node]       "x-ms-client-request-id": "dd013a81-b1ef-4cb4-a20c-7e4115ff06a9"
[Node]     }
[Node]   },
[Node]   "withCredentials": false,
[Node]   "timeout": 0,
[Node]   "keepAlive": true,
[Node]   "requestId": "dd013a81-b1ef-4cb4-a20c-7e4115ff06a9"
[Node] }
[Node] azure:storage-blob:info Response status code: 400
[Node] azure:storage-blob:info Headers: {
[Node]   "_headersMap": {
[Node]     "connection": "close",
[Node]     "content-length": "326",
[Node]     "content-type": "text/html; charset=us-ascii",
[Node]     "date": "Sun, 13 Sep 2020 19:25:33 GMT",
[Node]     "server": "Microsoft-HTTPAPI/2.0"
[Node]   }
[Node] }
[Node] 2020-09-13T19:25:33.635Z v1.0.0 [error] Error uploading files to blob storage. Ex: RestError: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
[Node] <HTML><HEAD><TITLE>Bad Request</TITLE>
[Node] <META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
[Node] <BODY><h2>Bad Request - Invalid Verb</h2>
[Node] <hr><p>HTTP Error 400. The request verb is invalid.</p>
[Node] </BODY></HTML>
[Node]
[Node] 2020-09-13T19:25:33.637Z v1.0.0 [error] RestError: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
[Node] <HTML><HEAD><TITLE>Bad Request</TITLE>
[Node] <META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
[Node] <BODY><h2>Bad Request - Invalid Verb</h2>
[Node] <hr><p>HTTP Error 400. The request verb is invalid.</p>
[Node] </BODY></HTML>
[Node]
[Node]     at new RestError (<redacted>\node_modules\@azure\core-http\dist\index.js:2237:28)
[Node]     at <redacted>\node_modules\@azure\core-http\dist\index.js:3030:25
[Node]     at processTicksAndRejections (internal/process/task_queues.js:97:5)

12.2.0-dev.20200901.1

[Node] azure:core-http:info ServiceClient: using custom request policies
[Node] azure:core-http:info ServiceClient: using custom request policies
[Node] azure:core-http:info ServiceClient: using custom request policies
[Node] upload
[Node] azure:storage-blob:info RetryPolicy: =====> Try=1 Primary
[Node] azure:storage-blob:info Request: {
[Node]   "streamResponseBody": false,
[Node]   "url": "<redacted>/46c30e91-ea6b-4f0c-be26-a2e9b6342db4.pdf?blockid=ZDZhNWYyMDktNThjYi00NTE2LWIzMDEtMjBkYzY0YTA0YzJlMDAwMDAwMDAwMDAw&comp=block",
[Node]   "method": "PUT",
[Node]   "headers": {
[Node]     "_headersMap": {
[Node]       "content-type": "application/octet-stream",
[Node]       "content-length": "42231",
[Node]       "x-ms-version": "2019-12-12",
[Node]       "user-agent": "azsdk-js-storageblob/12.2.0 (NODE-VERSION v12.16.3; Windows_NT 10.0.19042)",
[Node]       "x-ms-client-request-id": "046b1bf4-1cad-4f91-85f0-a521b02047ec"
[Node]     }
[Node]   },
[Node]   "withCredentials": false,
[Node]   "timeout": 0,
[Node]   "keepAlive": true,
[Node]   "requestId": "046b1bf4-1cad-4f91-85f0-a521b02047ec"
[Node] }
[Node] azure:storage-blob:info Response status code: 201
[Node] azure:storage-blob:info Headers: {
[Node]   "_headersMap": {
[Node]     "content-length": "0",
[Node]     "date": "Sun, 13 Sep 2020 20:07:10 GMT",
[Node]     "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
[Node]     "x-ms-client-request-id": "046b1bf4-1cad-4f91-85f0-a521b02047ec",
[Node]     "x-ms-content-crc64": "X181cPKpCPw=",
[Node]     "x-ms-request-id": "d2aa4be1-101e-0051-6209-8a2823000000",
[Node]     "x-ms-request-server-encrypted": "true",
[Node]     "x-ms-version": "2019-12-12"
[Node]   }
[Node] }
[Node] azure:storage-blob:info RetryPolicy: =====> Try=1 Primary
[Node] azure:storage-blob:info Request: {
[Node]   "streamResponseBody": false,
[Node]   "url": "<redacted>/46c30e91-ea6b-4f0c-be26-a2e9b6342db4.pdf?comp=blocklist",
[Node]   "method": "PUT",
[Node]   "headers": {
[Node]     "_headersMap": {
[Node]       "content-type": "application/xml; charset=utf-8",
[Node]       "x-ms-version": "2019-12-12",
[Node]       "user-agent": "azsdk-js-storageblob/12.2.0 (NODE-VERSION v12.16.3; Windows_NT 10.0.19042)",
[Node]       "x-ms-client-request-id": "07246208-b088-4076-ad76-caeef5f60ed7"
[Node]     }
[Node]   },
[Node]   "withCredentials": false,
[Node]   "timeout": 0,
[Node]   "keepAlive": true,
[Node]   "requestId": "07246208-b088-4076-ad76-caeef5f60ed7"
[Node] }
[Node] azure:storage-blob:info Response status code: 201
[Node] azure:storage-blob:info Headers: {
[Node]   "_headersMap": {
[Node]     "content-length": "0",
[Node]     "date": "Sun, 13 Sep 2020 20:07:10 GMT",
[Node]     "etag": "\"0x8D8582099945DD3\"",
[Node]     "last-modified": "Sun, 13 Sep 2020 20:07:11 GMT",
[Node]     "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
[Node]     "x-ms-client-request-id": "07246208-b088-4076-ad76-caeef5f60ed7",
[Node]     "x-ms-content-crc64": "uFYdO3euOCk=",
[Node]     "x-ms-request-id": "d2aa4be7-101e-0051-6609-8a2823000000",
[Node]     "x-ms-request-server-encrypted": "true",
[Node]     "x-ms-version": "2019-12-12"
[Node]   }
[Node] }