Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[storage-file-share] Fix empty continuation token with list methods #26676

Merged
merged 1 commit into from
Aug 1, 2023

Conversation

xirzec
Copy link
Member

@xirzec xirzec commented Aug 1, 2023

Packages impacted by this PR

@azure/storage-file-share

Describe the problem that is addressed by this PR

When the empty string was passed as a continuationToken to the byPage method of any list operation, the constructed url would have an empty marker parameter &marker=&.

This was causing issues with SharedKey authentication since we now share the same credential signing logic as storage-blob and the implementation of getURLQueries in storage-blob ignores query parameters without a value:

indexOfEqual > 0 && indexOfEqual === lastIndexOfEqual && lastIndexOfEqual < value.length - 1

However, the previous copy of this method in storage-file-share did not:

return indexOfEqual > 0 && indexOfEqual === lastIndexOfEqual;

Notice the missing && lastIndexOfEqual < value.length - 1 in the second implementation.

What are the possible designs available to address the problem? If there are more than one possible design, why was the one in this PR chosen?

While it is possible to change the way storage-blob does this signing to match storage-file-share, given that storage-blob is a far more popular package, there is considerable risk to changing behavior there.

Since existing storage-file-share customers (such as Storage Explorer) may be already passing the empty string today, there is a strong desire to maintain that contract.

Rather than diverge the signing logic around SharedKeyCredential again, I believe the least invasive fix is to have the list methods in storage-file-share ignore the empty string as demonstrated in this PR.

@xirzec xirzec self-assigned this Aug 1, 2023
@xirzec xirzec added Client This issue points to a problem in the data-plane of the library. Storage Storage Service (Queues, Blobs, Files) labels Aug 1, 2023
@azure-sdk
Copy link
Collaborator

API change check

API changes are not detected in this pull request.

@jeremymeng
Copy link
Member

Yes I believe we already doing that for most markers. I traced the change back to PR #4418 and looks that it is an intentional change e73327f.

@xirzec xirzec merged commit 82ab59c into Azure:main Aug 1, 2023
@xirzec xirzec deleted the fixFileShareEmptyMarker branch August 1, 2023 18:18
dgetu pushed a commit that referenced this pull request Sep 6, 2023
…26676)

### Packages impacted by this PR

`@azure/storage-file-share`

### Describe the problem that is addressed by this PR

When the empty string was passed as a continuationToken to the `byPage`
method of any `list` operation, the constructed url would have an empty
marker parameter `&marker=&`.

This was causing issues with SharedKey authentication since we now share
the same credential signing logic as `storage-blob` and the
implementation of `getURLQueries` in storage-blob ignores query
parameters without a value:

https://github.com/Azure/azure-sdk-for-js/blob/b4e1a63cd2499016f91852c7208f0c4c569651d4/sdk/storage/storage-blob/src/utils/utils.common.ts#L371

However, the previous copy of this method in `storage-file-share` did
not:

https://github.com/Azure/azure-sdk-for-js/blob/b4e1a63cd2499016f91852c7208f0c4c569651d4/sdk/storage/storage-file-share/src/utils/utils.common.ts#L306

Notice the missing `&& lastIndexOfEqual < value.length - 1` in the
second implementation.

### What are the possible designs available to address the problem? If
there are more than one possible design, why was the one in this PR
chosen?

While it is possible to change the way storage-blob does this signing to
match storage-file-share, given that storage-blob is a far more popular
package, there is considerable risk to changing behavior there.

Since existing storage-file-share customers (such as Storage Explorer)
may be already passing the empty string today, there is a strong desire
to maintain that contract.

Rather than diverge the signing logic around SharedKeyCredential again,
I believe the least invasive fix is to have the list methods in
storage-file-share ignore the empty string as demonstrated in this PR.
azure-sdk pushed a commit to azure-sdk/azure-sdk-for-js that referenced this pull request Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client This issue points to a problem in the data-plane of the library. Storage Storage Service (Queues, Blobs, Files)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants