Azure / azure-sdk-for-rust

This repository is for active development of the *unofficial* Azure SDK for Rust. This repository is *not* supported by the Azure SDK team.
MIT License
696 stars 241 forks source link

Fix find blob by tag #1622

Open rafamerlin opened 6 months ago

rafamerlin commented 6 months ago

There were 2 issues in here, one is that the API version got updated recently and that caused the response to be different than the one expected so querying blobs by tag wasn't working. I believe the version that the current main code has is the response for when we query with x-ms-version: 2019-12-12, however, we're now sending our requests with x-ms-version: 2022-11-02 which caused this to completely break.

Another item was when we add multiple tags to the where expression, that was failing because of the way the URL was being encoded and that doesn't seem to be accepted by Azure REST API.

I've been using a workaround branch that was still using the old API for quite a while without any issues with this URL fix, related to this issue I raised a while ago https://github.com/Azure/azure-sdk-for-rust/issues/1284

The error seems to have changed on the new API version as without the make_url_compatible_with_api if we query anything with more than 1 tag in the filter we get this error:

<?xml version="1.0" encoding="utf-8"?>
<Error>
    <Code>AuthenticationFailed</Code>
    <Message>Server failed to authenticate the request. Make sure the value of Authorization header
        is formed correctly including the
        signature.RequestId:602fdf47-a01e-0010-5d99-732f4c000000Time:2024-03-11T09:50:11.4905786Z</Message>
    <AuthenticationErrorDetail>
        The MAC signature found in the HTTP request
        &apos;{{redacted}}&apos; is not the same as any computed
        signature. Server used following string to sign: &apos;GETx-ms-date:Mon, 11 Mar 2024
        09:50:06
        GMTx-ms-version:2022-11-02/{{redacted}}/comp:blobswhere:@container=&apos;unit-tests-with-index&apos;+AND+tagis=&apos;a&apos;&apos;.</AuthenticationErrorDetail>
</Error>

One question I have regarding the extra structs I had to add to have the response matching the new format of the XML for the tag content, do we need that at all? I was wondering if we could just drop the tag content as it doesn't seem like it's being used anywhere. Happy to keep it though in case there's any intention of using it in the future or if we want it for information purposes.

heaths commented 6 months ago

@seanmcc-msft is this a known breaking change to the format?

rafamerlin commented 6 months ago

I took the chance to hook up the MaxResults into FindBlobsByTagsBuilder as it wasn't doing anything, removed the next_marker on the input and change it to Marker to match the ListBlobsBuilder and made the next_marker public on the response so we can actually use it.

heaths commented 5 months ago

@seanmcc-msft is there anyone on your team that can review this? It's mostly service-related code.

seanmcc-msft commented 5 months ago

@jaschrep-msft @vincenttran-msft @jalauzon-msft please take a look.