Azure / azure-sdk-for-js

This repository is for active development of the Azure SDK for JavaScript (NodeJS & Browser). For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/javascript/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-js.
MIT License
2.09k stars 1.2k forks source link

azure/blob-storage uploadStream and MissingRequiredHeader #31744

Open pt-kojoa opened 1 day ago

pt-kojoa commented 1 day ago

Hello,

could someone help resolve this weird blob storage uploadStream case?

I have set up blob storage to Azure account number 1 and SAS token for the container. Blob gets uploaded just fine. On Azure account number 2 there is similar blob storage setup but suddenly API gives an error. Below attached the SDK error:

{
    "name": "RestError",
    "code": "MissingRequiredHeader",
    "statusCode": 400,
    "details": {
        "errorCode": "MissingRequiredHeader",
        "content-length": "301",
        "content-type": "application/xml",
        "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
        "x-ms-request-id": "REDACTED",
        "x-ms-version": "2024-11-04",
        "x-ms-client-request-id": "REDACTED",
        "date": "Wed, 13 Nov 2024 10:58:16 GMT",
        "message": "An HTTP header that's mandatory for this request is not specified.\nRequestId:REDACTED\nTime:2024-11-13T10:58:16.8205243Z",
        "code": "MissingRequiredHeader",
        "HeaderName": "x-ms-blob-type"
    },
    "request": {
        "url": "https://REDACTED.blob.core.windows.net/REDACTED/hello.txt?sv=REDACTED&ss=REDACTED&srt=REDACTED&sp=REDACTED&se=REDACTED&st=REDACTED&sip=REDACTED&spr=REDACTED&Sig=REDACTED&comp=REDACTED&blockid=REDACTED",
        "headers": {
            "content-type": "application/octet-stream",
            "x-ms-version": "REDACTED",
            "content-length": "20",
            "accept": "application/xml",
            "user-agent": "azsdk-js-azure-storage-blob/12.25.0 core-rest-pipeline/1.17.0 Node/18.20.4 OS/(x64-Linux-5.10.226-235.879.amzn2.x86_64)",
            "x-ms-client-request-id": "REDACTED"
        },
        "method": "PUT",
        "timeout": 0,
        "disableKeepAlive": false,
        "streamResponseStatusCodes": {},
        "withCredentials": false,
        "tracingOptions": {
            "tracingContext": {
                "_contextMap": {}
            }
        },
        "requestId": "REDACTED",
        "allowInsecureConnection": true,
        "enableBrowserStreams": false
    }
}

And here is minimal code to reproduce the error (although it seems it works and doesn't depending on Azure account):

    const blobServiceClient = new BlobServiceClient(
      'https://REDACTED.blob.core.windows.net?REDACTED_SAS_TOKEN'
    );

    const containerClient = blobServiceClient.getContainerClient('REDACTED_CONTAINER_NAME');
    const blockBlobClient = containerClient.getBlockBlobClient('REDACTED_FILE_NAME');

    const result = await blockBlobClient.uploadStream(
      readableStream
    );

uploadStream doesn't seem to allow me to add that header?

github-actions[bot] commented 1 day ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @xgithubtriage.