question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Azure Storage Files] Bug with getting shared access signature

See original GitHub issue
  • Package Name: @azure/storage-file-share
  • Package Version: 12.2.0
  • Operating system: macOS
  • nodejs
    • version: 10.16.3
  • browser
    • name/version:
  • typescript
    • version:
  • Is the bug related to documentation in

Describe the bug

2 Issues actually:

  1. When fetching access policies for a file share that has null value for either the start date or end date results in invalid date for that null value.

  2. Getting a Type Error exception occurs while fetching access policies when an access policy has only defined an identifier and nothing else i.e. null start/end date and no permissions.

TypeError: Cannot read property 'expiresOn' of undefined
    at ShareClient.<anonymous> (ShareClient.ts:993)

The issue is coming from the following lines of code:

      for (const identifier of response) {
        res.signedIdentifiers.push({
          accessPolicy: {
            expiresOn: new Date(identifier.accessPolicy!.expiresOn!),
            permissions: identifier.accessPolicy!.permissions!,
            startsOn: new Date(identifier.accessPolicy!.startsOn!)
          },
          id: identifier.id
        });
      }

Two issues with the code above:

  1. It does not check whether expiresOn and startsOn are defined and not null in accessPolicy. This would cause the 1st issue I mentioned above.

  2. If I create an access policy with just an identifier, then the result will not even have an accessPolicy element. This is causing the 2nd issue.

I looked up code for getAccessPolicy method on QueueClient here: https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/storage/storage-queue/src/QueueClient.ts#L934, and it is implemented correctly.

      for (const identifier of response) {
        let accessPolicy: any = undefined;
        if (identifier.accessPolicy) {
          accessPolicy = {
            permissions: identifier.accessPolicy.permissions
          };

          if (identifier.accessPolicy.expiresOn) {
            accessPolicy.expiresOn = new Date(identifier.accessPolicy.expiresOn);
          }

          if (identifier.accessPolicy.startsOn) {
            accessPolicy.startsOn = new Date(identifier.accessPolicy.startsOn);
          }
        }

        res.signedIdentifiers.push({
          accessPolicy,
          id: identifier.id
        });
      }

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ljian3377commented, Oct 22, 2020

The next GA release would be in the early November.

0reactions
msftbot[bot]commented, Nov 18, 2020

Hi, we’re sending this friendly reminder because we haven’t heard back from you in a while. We need more information about this issue to help address it. Please be sure to give us your input within the next 7 days. If we don’t hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Grant limited access to Azure Storage resources using shared ...
A shared access signature is a signed URI that points to one or more storage resources. The URI includes a token that contains...
Read more >
[BUG] Azure Blob Storage - When using a Shared Access Key ...
Describe the bug I'm using a connection string like the following with BlobServiceClient: DefaultEndpointsProtocol=https;AccountName= ;AccountKey= ...
Read more >
Shared Access Signature not working in Azure Files with ...
UPDATE WITH THE ANSWER. As correctly surmised by Gaurav Mantri, the problem was in the GetCloudFile method, where I wasn't even looking.
Read more >
Azure Shared Access Signature | Storage Account ... - YouTube
Azure SAS | Azure Shared Access Signature | Storage Account Shared Access | How to generate Storage Account Shared Access Signature with ....
Read more >
Uploading Files to Azure Blob Storage with Shared Access ...
Shared Access Signature (SAS) provides a secure way to upload and download files from Azure Blob Storage without sharing the connection ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found