Skip to content

Save document through upsert_item failed when the document has non-ascii characters #40373

Closed as not planned
@lidingshan

Description

@lidingshan
  • Package Name: azure-cosmos
  • Package Version: 4.9.0
  • Operating System: macOs 15.4 (Apple M3)
  • Python Version: 3.11

Describe the bug
when calling upsert_item to save a document, if the document includes non-ascii characters, an exception will be raised, which is
unsupported Unicode escape sequence

To Reproduce
Steps to reproduce the behavior:

  1. Create a test container "Users"
  2. Call upsert_item to save data like {"id": "1234", "partitionId": "London", "name": "なかむらし"}

Expected behavior
The document has non-ascii characters that should be saved successfully

Additional context
I believe the root cause is the implementation of _request_body_from_data function in _synchronized_request.py, which should use json.dumps with ensure-ascii=False

Metadata

Metadata

Assignees

Labels

ClientThis issue points to a problem in the data-plane of the library.CosmosService AttentionWorkflow: This issue is responsible by Azure service team.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-author-feedbackWorkflow: More information is needed from author to address the issue.no-recent-activityThere has been no recent activity on this issue.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions