[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
- README.md
- source code documentation
- SDK API docs on https://docs.microsoft.com
Describe the bug
2 Issues actually:
-
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. -
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:
-
It does not check whether
expiresOn
andstartsOn
are defined and not null inaccessPolicy
. This would cause the 1st issue I mentioned above. -
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:
- Created 3 years ago
- Comments:8 (5 by maintainers)
Top GitHub Comments
The next GA release would be in the early November.
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!