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

[BUG] Single quote in PartitionKey not serialized properly in PATCH entity #21635

Closed
joelverhagen opened this issue Jun 5, 2021 · 2 comments · Fixed by #21650
Closed

[BUG] Single quote in PartitionKey not serialized properly in PATCH entity #21635

joelverhagen opened this issue Jun 5, 2021 · 2 comments · Fixed by #21650
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Tables

Comments

@joelverhagen
Copy link
Contributor

Describe the bug
When the Table entity partition key contains single quotes, the PATCH operation (where the PK is part of the URL path, not query string) fails. The single quote is URL encoded as %27. The legacy SDK escapes it with two single quotes.

Found while trying to fix Azure/Azurite#790.

Expected behavior
It should escape the single quote in a way that Table storage expects.

Actual behavior (include Exception or Stack Trace)

Unhandled exception. Azure.RequestFailedException: Bad Request - Error in query syntax.
RequestId:6539ca23-b002-0045-4051-5a7235000000
Time:2021-06-05T21:29:07.6478169Z
Status: 400 (Bad Request)
ErrorCode: InvalidInput

Content:
{"odata.error":{"code":"InvalidInput","message":{"lang":"en-US","value":"Bad Request - Error in query syntax.\nRequestId:6539ca23-b002-0045-4051-5a7235000000\nTime:2021-06-05T21:29:07.6478169Z"}}}

Headers:
Transfer-Encoding: chunked
Server: Windows-Azure-Table/1.0,Microsoft-HTTPAPI/2.0
x-ms-request-id: 6539ca23-b002-0045-4051-5a7235000000
x-ms-client-request-id: 69ef5d19-5496-4a12-a0f5-3baa9a331b28
x-ms-version: REDACTED
X-Content-Type-Options: REDACTED
Date: Sat, 05 Jun 2021 21:29:07 GMT
Content-Type: application/json; odata=minimalmetadata; streaming=true; charset=utf-8

   at Azure.Data.Tables.TableRestClient.MergeEntity(String table, String partitionKey, String rowKey, Nullable`1 timeout, String ifMatch, IDictionary`2 tableEntityProperties, QueryOptions queryOptions, CancellationToken cancellationToken)
   at Azure.Data.Tables.TableClient.UpsertEntity[T](T entity, TableUpdateMode mode, CancellationToken cancellationToken)
   at ConsoleApp1.Program.Main(String[] args) in C:\Users\joelv\Desktop\ConsoleApp1\ConsoleApp1\Program.cs:line 31
   at ConsoleApp1.Program.<Main>(String[] args)

To Reproduce

using System;
using System.Linq;
using System.Threading.Tasks;
using Azure;
using Azure.Data.Tables;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Table;

namespace ConsoleApp1
{
    class Program
    {
        const string ConnectionString = "UseDevelopmentStorage=true";
        const string TableName = "azuritetest";

        static async Task Main(string[] args)
        {
            {
                var account = CloudStorageAccount.Parse(ConnectionString);
                var tableServiceClient = account.CreateCloudTableClient();
                var table = tableServiceClient.GetTableReference(TableName);
                await table.CreateIfNotExistsAsync();
                await table.ExecuteAsync(TableOperation.InsertOrMerge(new Microsoft.WindowsAzure.Storage.Table.TableEntity("Isn't this a nasty PK", "rk")));
            }

            {
                var tableServiceClient = new TableServiceClient(ConnectionString);
                var tableClient = tableServiceClient.GetTableClient(TableName);
                await tableClient.CreateIfNotExistsAsync();
                tableClient.UpsertEntity(new Azure.Data.Tables.TableEntity("Isn't this a nasty PK", "rk"));
            }
        }
    }
}

Environment:

  • Name and version of the Library package used: Azure.Data.Tables 12.0.0-alpha.20210603.1
  • Hosting platform or OS and .NET runtime version (dotnet --info output for .NET Core projects): .NET SDK 5.0.300
  • IDE and version : VS 16.10
@ghost ghost added needs-triage This is a new issue that needs to be triaged to the appropriate team. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Jun 5, 2021
@jsquire jsquire added Client This issue points to a problem in the data-plane of the library. needs-team-attention This issue needs attention from Azure service team or SDK team Tables labels Jun 7, 2021
@ghost ghost removed the needs-triage This is a new issue that needs to be triaged to the appropriate team. label Jun 7, 2021
@jsquire
Copy link
Member

jsquire commented Jun 7, 2021

Hi @joelverhagen. Thanks for your continued help improving the Tables experience. Tagging and routing to the team member best able to assist.

@christothes
Copy link
Member

Thanks @joelverhagen , nice find!

azure-sdk pushed a commit to azure-sdk/azure-sdk-for-net that referenced this issue Nov 25, 2022
[Hub Generated] Publish private branch 'servicelinker/update-readme-apiversion' (Azure#21635)

* add or modify files

* hide unused changes

* eliminate diff from private repo
@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Tables
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants