Azure / azure-sdk-for-java

This repository is for active development of the Azure SDK for Java. For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/java/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-java.
MIT License
2.31k stars 1.96k forks source link

Java SDK encodes the blob name (.NET & Nodejs are preserving the slashes) #40370

Open viswanr opened 3 months ago

viswanr commented 3 months ago

Describe the bug We are running an integration test written in Typescript using Docker, where we have a container with our Java Function app an d it calls to into Azurite, the official storage emulator from Azure. The Java Azure Function is running in Docker along with Azurite within the same network.

The PUT request to upload the file to Azurite is as follows, which is successful: "PUT /devstoreaccount1/tdigests/hourlyDigests/v2/EMEA/t2_1/ChatSwitch/eyJBcHBJbmZvX0NsaWVudFR5cGUiOiJ3ZWIiLCJBcHBJbmZvX0Vudmlyb25tZW50IjoicHJvZCIsIkFwcEluZm9fRXhwZXJpZW5jZU5hbWUiOiJyZWFjdC13ZWItY2xpZW50IiwiRGVyaXZlZF9Vc2VySW5mb19FZHVUeXBlIjoiRURVIiwiY29udGV4dFR5cGUiOiJ0Ml8xIiwiZXZlbnROYW1lIjoiY2hhdF9zd2l0Y2giLCJncm91cGluZ05hbWUiOiJBcHBJbmZvX0NsaWVudFR5cGUiLCJtZXRyaWNLaW5kIjoibGF0ZW5jeSJ9/2024-04-07/21/tdigests.json HTTP/1.1" 201

Now, when we look at the URL that the Java app is using for the GET request,

"GET /devstoreaccount1/tdigests/hourlyDigests%2Fv2%2FROW%2Ft2_1%2FChatSwitch%2FeyJBcHBJbmZvX0NsaWVudFR5cGUiOiJ3ZWIiLCJBcHBJbmZvX0Vudmlyb25tZW50IjoicHJvZCIsIkFwcEluZm9fRXhwZXJpZW5jZU5hbWUiOiJyZWFjdC13ZWItY2xpZW50IiwiRGVyaXZlZF9Vc2VySW5mb19FZHVUeXBlIjoiRURVIiwiY29udGV4dFR5cGUiOiJ0Ml8xIiwiZXZlbnROYW1lIjoiY2hhdF9zd2l0Y2giLCJncm91cGluZ05hbWUiOiJTY2VuYXJpb19TdGF0dXMiLCJtZXRyaWNLaW5kIjoibGF0ZW5jeSJ9%2F2024-04-07%2F23%2Ftdigests.json HTTP/1.1" 404

As you can see, the slashes in the path are being encoded. Consequently, this is causing the following 404 issue where it cannot find the blob (since the path is wrong because of the encoding). The download path is not encoded before the GET request is sent, but it seems like it is getting encoded during transit to Azurite.

This behavior seems to happen only in the Java SDK. We have similar setups with .NET and Nodejs Function apps, and they work well with Azurite. https://github.com/Azure/azure-sdk-for-net/pull/30271

Exception or Stack Trace The request to Blob Store through the Azure SDK encodes the blob name leading to failures with Azure Storage Simulators.

To Reproduce

  1. Use docker-compose to create a container with a Java Function app and an Azurite Instance
  2. As part of test, upload a file to Azurite Instance using Typescript Blob Store SDK
  3. Read the file from the Java Function app

[Expected] The file is read successfully.

[Actual] The request returns 404, Blob not found

Setup (please complete the following information):

If you suspect a dependency version mismatch (e.g. you see NoClassDefFoundError, NoSuchMethodError or similar), please check out Troubleshoot dependency version conflict article first. If it doesn't provide solution for the problem, please provide:

Additional context Add any other context about the problem here.

Information Checklist Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report


### Tasks
- [x] Add a draft title or issue reference here
- [x] Repro Steps Added
- [x] Setup information Added
github-actions[bot] commented 3 months ago

@ibrahimrabab @ibrandes @seanmcc-msft

github-actions[bot] commented 3 months ago

Thank you for your feedback. Tagging and routing to the team member best able to assist.