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

Character '"' is not valid at position 20 in 'PartitionKey='"A'aaa"_bbbb3',RowKey='"A'aaa"_bbbb3''. #20301

Closed
646826 opened this issue Aug 16, 2021 · 10 comments
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. issue-addressed The Azure SDK team member assisting with this issue believes it to be addressed and ready to close. Tables

Comments

@646826
Copy link

646826 commented Aug 16, 2021

  • Package Name: azure-data-tables
  • Package Version: 12.1.0
  • Operating System: Linux and Windows
  • Python Version: 3.8

Describe the bug

TableTransactionError: 0:Syntax error: character '"' is not valid at position 20 in 'PartitionKey='"A'aaa"_bbbb3',RowKey='"A'aaa"_bbbb3''.
RequestId:8452bf63-8002-0099-18eb-9265f1000000
Time:2021-08-16T22:08:14.5833819Z
ErrorCode:InvalidInput
---------------------------------------------------------------------------
TableTransactionError                     Traceback (most recent call last)
/Untitled-1.py in 
     15 azure_table_client = TableServiceClient(endpoint=f"https://{account_name}.table.core.windows.net", credential=credential)
     16 azure_table_service = azure_table_client .create_table_if_not_exists(to_table_name)
---> 17 azure_table_service .submit_transaction(batch)

/usr/local/lib/python3.8/site-packages/azure/data/tables/_table_client.py in submit_transaction(self, operations, **kwargs)
    729             except AttributeError:
    730                 raise ValueError("Unrecognized operation: {}".format(operation[0]))
--> 731         return self._batch_send(*batched_requests.requests, **kwargs)  # type: ignore

/usr/local/lib/python3.8/site-packages/azure/data/tables/_base_client.py in _batch_send(self, *reqs, **kwargs)
    301                     error_message="The transaction request was too large",
    302                     error_type=RequestTooLargeError)
--> 303             raise _decode_error(
    304                 response=error_parts[0],
    305                 error_type=TableTransactionError

TableTransactionError: 0:Syntax error: character '"' is not valid at position 20 in 'PartitionKey='"A'aaa"_bbbb3',RowKey='"A'aaa"_bbbb3''.
RequestId:8452bf63-8002-0099-18eb-9265f1000000
Time:2021-08-16T22:08:14.5833819Z
ErrorCode:InvalidInput

To Reproduce
Steps to reproduce the behavior:
pip install azure-data-tables

from azure.core.credentials import AzureNamedKeyCredential
from azure.data.tables import TableServiceClient
from azure.data.tables import TableEntity

account_name=""
account_key=""
to_table_name=""

batch = []
g = TableEntity({"PartitionKey":"\"A'aaa\"_bbbb3", "RowKey":"\"A'aaa\"_bbbb3", "test":"\"A'aaa\"_bbbb3"})
batch.append(("upsert", TableEntity(g)))

credential = AzureNamedKeyCredential(account_name, account_key)
azure_table_client = TableServiceClient(endpoint=f"https://{account_name}.table.core.windows.net", credential=credential)
azure_table_service = azure_table_client.create_table_if_not_exists(to_table_name)
azure_table_service.submit_transaction(batch)

Expected behavior

  • I want to create this PartitionKey: "A'aaa"_bbbb3
  • I want to use this value "A'aaa"_bbbb3 for rows

Screenshots
image

Additional context
I was able to use these values via:

Microsoft Azure Storage Explorer version 1.20.1
image
and Storage Explorer (preview) at https://portal.azure.com/
image

#Update from me
I tried loading data through query_entities, I got this result:

{'PartitionKey': '"A\'aaa"_bbbb2',
 'RowKey': '"A\'aaa"_bbbb2',
 'test': '"A\'aaa"_bbbb2'}

image

After that, I tried to use the response to send this data to the server but I got the same error.

@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 Aug 16, 2021
@ghost ghost removed the needs-triage This is a new issue that needs to be triaged to the appropriate team. label Aug 16, 2021
@annatisch
Copy link
Member

Thanks for the report @646826!
Looking at the service documentation - the partition key and row key values here should be valid. So this seems like a bug in the SDK.

Have you tried the same upsert operation as a single request rather than a transaction (e.g. client.upsert_entity(...))?
Additionally - looking at your code sample - you shouldn't need to wrap your input entity in TableEntity, the following should also be valid:

batch = []
g = {"PartitionKey":"\"A'aaa\"_bbbb3", "RowKey":"\"A'aaa\"_bbbb3", "test":"\"A'aaa\"_bbbb3"}
batch.append(("upsert", g))

I will try to repro this in a test asap.

@646826
Copy link
Author

646826 commented Aug 16, 2021

Thanks for the report @646826!
Looking at the service documentation - the partition key and row key values here should be valid. So this seems like a bug in the SDK.

Have you tried the same upsert operation as a single request rather than a transaction (e.g. client.upsert_entity(...))?
Additionally - looking at your code sample - you shouldn't need to wrap your input entity in TableEntity, the following should also be valid:

batch = []
g = {"PartitionKey":"\"A'aaa\"_bbbb3", "RowKey":"\"A'aaa\"_bbbb3", "test":"\"A'aaa\"_bbbb3"}
batch.append(("upsert", g))

I will try to repro this in a test asap.

I spent a lot of time trying to write/update this data to a table. And I was not completely sure where the problem was, so I tried all possible options. I have added some additional information to the bug, please see above.

@lmazuel lmazuel added the Client This issue points to a problem in the data-plane of the library. label Aug 17, 2021
@ghost ghost added the needs-team-attention This issue needs attention from Azure service team or SDK team label Aug 17, 2021
@YalinLi0312 YalinLi0312 added this to the [2021] September milestone Aug 17, 2021
@annatisch
Copy link
Member

Thanks for your patience - I was able to successfully repro this locally. Investigating the cause now :)

@annatisch
Copy link
Member

Okay - I have found the cause for this. It's the single quote character ', the service requires that this be escaped via duplication.
For example, the entity you have in your example:

g = {"PartitionKey":"\"A'aaa\"_bbbb3", "RowKey":"\"A'aaa\"_bbbb3", "test":"\"A'aaa\"_bbbb3"}

When sent over the wire, would need to be formatted like this:

g = {"PartitionKey":"\"A''aaa\"_bbbb3", "RowKey":"\"A''aaa\"_bbbb3", "test":"\"A'aaa\"_bbbb3"}

This is working correctly for deserialization, but not serialization.
I will PR a fix this week to ship in the September release.

@annatisch
Copy link
Member

Sorry for the delay - finally got the PR out for this fix:
#20386

Tagged @YalinLi0312 for review :)

@YalinLi0312
Copy link
Member

Fixed.

@annatisch annatisch reopened this Sep 8, 2021
@annatisch
Copy link
Member

Unfortunately we have moved this release to the beginning of October. We are still waiting on cross-language consensus on whether this should be considered a breaking change, and if not, how an 'opt-out' strategy will be adopted for each SDK.

Current opt-out strategy for Python is implemented in this PR, pending further design discussions:
#20603

I have reopened this issue for now.

@annatisch
Copy link
Member

This bug fix has now been released :)

@annatisch annatisch added the issue-addressed The Azure SDK team member assisting with this issue believes it to be addressed and ready to close. label Nov 15, 2021
@ghost
Copy link

ghost commented Nov 15, 2021

Hi @646826. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text “/unresolve” to remove the “issue-addressed” label and continue the conversation.

@ghost ghost removed the needs-team-attention This issue needs attention from Azure service team or SDK team label Nov 15, 2021
@annatisch annatisch removed the question The issue doesn't require a change to the product in order to be resolved. Most issues start as that label Nov 15, 2021
@ghost
Copy link

ghost commented Nov 23, 2021

Hi @646826, since you haven’t asked that we “/unresolve” the issue, we’ll close this out. If you believe further discussion is needed, please add a comment “/unresolve” to reopen the issue.

@ghost ghost closed this as completed Nov 23, 2021
azure-sdk pushed a commit to azure-sdk/azure-sdk-for-python that referenced this issue Sep 19, 2022
Network 2022 05 01 (Azure#20695)

* Adds base for updating Microsoft.Network from version stable/2022-01-01 to version 2022-05-01

* Updates readme

* Updates API version in new specs and examples

* add DisableTcpStateTracking on nic (Azure#19734)

Co-authored-by: Dan Tu <dantu@microsoft.com>

* Adding new VIP Swap APIs to support extension resource design (Azure#19698)

* Adding new VIP Swap APIs to support extension resource design

* fixing validation checks

* minor fix

* Reverting changes

* Minor fix to add a new line

* fix description (Azure#19987)

Co-authored-by: Dan Tu <dantu@microsoft.com>

* Add BillingType Property to ExpressRoutePorts (Azure#19932)

* change port json

* changes

* add Virtual network gateway policy group api (Azure#19766)

* finish update on connection configuration references

* resolve reference error

* finish prettier

* resolve sematic error

* finish update change

* enablePrivateLinkFastPath property for VirtualNetworkGatewayConnection resource (Azure#20050)

* Support for Per Rule Actions in Application Gateway WAF (Azure#20027)

* Adding changes for per rule actions

* Fixing spaces

* prettier fix

* Addressing PR comments

* Address review comments

* Add ColoLocation to ExpressRoutePort result (Azure#20033)

* Add ColoLocation to ExpressRoutePort result

* Fix automation code check error

* Merge from network-2022-05-01

* Revert "Merge from network-2022-05-01"

This reverts commit f0671a040b2bad684921f8f8ad4b53bb0f4b4a93.

Co-authored-by: Jianqi Zhao <jianzhao@microsoft.com>

* DDoS Per IP SKU + Custom Policy Deprecation Swagger PR (Azure#19985)

* initial changes

* example file changes

* new files for new apis

* adding a period

* changing reference

* prettier fixes

* ddos fix

* lint diff fixes

* more lint diff errors

* fixing operation id

* changing bool to string enum

* example changes

* adding 202s as these are long running ops

* examples

Co-authored-by: Manas Chakka <manaschakka@microsoft.com>

* Adding UnhealthyThreshold property to LB health probes, and updated examples with new property (Azure#20001)

* Property to enable/disable OCSP revocation check on client certificate (Azure#20301)

* add new property to enable/disable OCSP revocation check on client certificate for MTLS

* revert breaking change of updating enum property

* Add new parameter asn, geo and expressRouteAdvertise to CustomIPPrefix for new 2022-05-01 nrp sdk version (Azure#20266)

* fix

* fix

* fix

* fix

* fix

* fix

Co-authored-by: Weiheng Li <weihl@microsoft.com>

* Network 2022-05-01 Azure Virtual Network Manager Contributions (Azure#20440)

* Add third NIP enum for avnm security admin config, AllowRulesOnly

* add optional top parameters to various network manager post APIs

* revise all example input subscriptions to all zero guid

* change all top parameter max value to 100

* Revert "change all top parameter max value to 100"

This reverts commit 12943d2f2b91b22f1dae232cb291a8551fedfdca.

Co-authored-by: Jared Gorthy <jaredgorthy@microsoft.com>

* Alpelled waf manifest 05 01 2022 (Azure#20047)

* init

* init

* fix comments

* fix err

* try ref to appgw def

* try ref to appgw def

* try ref to appgw def

* try ref to appgw def

* update example

* update example

* update example

* update state and action

* update state and action

* change ruleset name and add tiers

* cammel case fix

* cammel case fix

* s_ruleid

* s_RuleId

* suppress s_RuleId camel case issue

* suppress s_RuleId camel case issue

* address comments

* address comments

* address comments

* fix typo

* cont fix

* cont fix

* cont fix

* cont fix

* cont fix

* add pageable

* add next link

Co-authored-by: Alon Pelled <alpelled@microsoft.com>

* Add prefixType property to CustomIPPrefix for NRP 2022-05-01 (Azure#20486)

* add prefixType parameter

* add example

* Adding swagger changes for routemaps feature (Azure#20091)

* initial changes for routemaps

* run npm prettier script

* adding examples

* fixing validation errors

* more validations

* more fixes

* trying to fix lint error

* fix for match condition

* renaming ActionType to fix lint

* fix for python sdk generation

* renaming Rule to RouteMapRule

* modify examples to remove vnetroutes from non hub vnet conns

* cleanup

* Added Upper-case transform (Azure#20674)

Co-authored-by: dtuCloud <tudan0103@gmail.com>
Co-authored-by: Dan Tu <dantu@microsoft.com>
Co-authored-by: shnaya434 <67019054+shnaya434@users.noreply.github.com>
Co-authored-by: nimaller <71352534+nimaller@users.noreply.github.com>
Co-authored-by: tyrannicrex <jiaczh@microsoft.com>
Co-authored-by: Jesus Arango <jearango@microsoft.com>
Co-authored-by: Sindhu Aluguvelli <sindhureddy216@gmail.com>
Co-authored-by: Jianqi Zhao <archie.j.zhao@gmail.com>
Co-authored-by: Jianqi Zhao <jianzhao@microsoft.com>
Co-authored-by: Manas Chakka <mchakka@gmail.com>
Co-authored-by: Manas Chakka <manaschakka@microsoft.com>
Co-authored-by: bhavanabheem <109241669+bhavanabheem@users.noreply.github.com>
Co-authored-by: biaogao <biga@microsoft.com>
Co-authored-by: Weiheng Li <weihengli.tj@gmail.com>
Co-authored-by: Weiheng Li <weihl@microsoft.com>
Co-authored-by: jago2136 <42753636+jago2136@users.noreply.github.com>
Co-authored-by: Jared Gorthy <jaredgorthy@microsoft.com>
Co-authored-by: alon-microsoft <31221093+alon-microsoft@users.noreply.github.com>
Co-authored-by: Alon Pelled <alpelled@microsoft.com>
Co-authored-by: Eric Hoffmann <112216215+erichoffmannms@users.noreply.github.com>
Co-authored-by: arganapathy <109313670+arganapathy@users.noreply.github.com>
Co-authored-by: rahulbissa2727 <106511944+rahulbissa2727@users.noreply.github.com>
@github-actions github-actions bot locked and limited conversation to collaborators Apr 11, 2023
This issue was closed.
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. issue-addressed The Azure SDK team member assisting with this issue believes it to be addressed and ready to close. Tables
Projects
None yet
Development

No branches or pull requests

4 participants