Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Storage] Fixed an issue of: StoragePipelineOptions is not passed con…
…structor correctly (#25516) Fixed an issue of: StoragePipelineOptions is not passed into constructors for blob clients correctly when using undefined as credential parameter. Repro code is like: ``` const options: StoragePipelineOptions = { keepAliveOptions: { enable: false }, retryOptions: { maxTries: 1, maxRetryDelayInMs: 0, retryDelayInMs: 0 } } const blockBlobClient = new BlockBlobClient(sasUrl.sasTokenUri, undefined, options); ``` The issue is because: BlobClient and BlockBlobClient supports constructor with parameters like: ``` constructor( connectionString: string, containerName: string, blobName: string, // Legacy, no fix for eslint error without breaking. Disable it for this interface. /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options*/ options?: StoragePipelineOptions ); constructor( url: string, credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential, // Legacy, no fix for eslint error without breaking. Disable it for this interface. /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options*/ options?: StoragePipelineOptions ); ``` StoragePipelineOptions can be the third or the forth parameter. It chooses the forth parameter as StoragePipelineOptions while an undefined credential is used, but the third one is the correct one. Note: 1. No such issue in other storage SDKs, because in other storage SDKs StoragePipelineOptions is always the third parameter. 2. PageBlobClient/AppendBlobClient doesn't have this issue, because they don't support nullable credential object. For BlobClient/BlockBlobClient, following code can work around the issue: `const blockBlobClient = new BlockBlobClient(sasUrl.sasTokenUri, new AnonymousCredential(), options);` 3. Currently we have no way to test whether the option has been passed into the client with unit test. I have manually test it against an injected service.
- Loading branch information