Skip to content

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

Open
@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

No one assigned

    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-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions