Azure / Azurite

A lightweight server clone of Azure Storage that simulates most of the commands supported by it with minimal dependencies
MIT License
1.83k stars 325 forks source link

Listing blobs with `prefix` query parameter sent as `Prefix` works in production but not in Azurite #465

Open katmsft opened 4 years ago

katmsft commented 4 years ago

Only tested the prefix but there could be more occurrences. It seems that the query parameter is not case-sensitive for production but is case-sensitive for Azurite, there will be an inconsistent behavior.

The HTTP protocol does not guarantee the casing for a query parameter, it is service behavior to ignore case:

The query string part is available to the server as it is. You can readily use mixed-case as you like, or discard the case (toLowerCase(...)). This also means that using a base64-encoded keys will work. You can't expect the users to type that correctly, though.

Linking to a PHP SDK issue: https://github.com/Azure/azure-storage-php/issues/235

XiaoningLiu commented 4 years ago

Azurite targets to align with all public documented behaviors of Azure Storage. prefix parameter in following document is lowercase.

In https://docs.microsoft.com/en-us/rest/api/storageservices/list-blobs#uri-parameters,

It's un documented behaior that Azure Storage handles prefix query parameter case insensitively.

We are still thinking what's the best Azurite strategy to align with Azure Storage production especially for the undocumented behaviors.

It's not easy to update in Azurite side to make it case insensitive, because related code are auto generated from predefined swagger, in swagger prefix parameter is lowercased. We will see how to do that, but it takes time.

In the same time, storage PHP SDK can have take this one line change to unblock customers and align with other Storage SDKs.

subhaze commented 4 years ago

@katmsft I agree that a one-to-one behavior would be nice but I also agree with @XiaoningLiu on supporting the documented casing for the query params even though Azure Storage production allows for case-insensitivity unfortunately.

I've sent a PR that just updated the QPs listed in the doc link above but I can dig further into the documentation and update the PR with any other lowercasing that may be needed to match docs if you're willing to merge it.

Thanks!

katmsft commented 4 years ago

Well, a fix like this does not work properly, as the QPs are also used in parsing the list result, which by official document should be mixed cases.

See this: https://docs.microsoft.com/en-us/rest/api/storageservices/list-blobs#response-body

subhaze commented 4 years ago

Ah, I see, hmm... Nothing is ever easy, ha!

Thoughts on separating that out so that query params can match the lower case per docs and the XML can match the Response Body case per docs?

Something like XTAG_PREVIEW, XTAG_MAX_RESULTS, ... like others that are defined here.