customer opt-in for ascii expansion - #48914
Conversation
|
@sdkReviewAgent-2 |
|
/azp run python - cosmos - tests |
|
Azure Pipelines: Successfully started running 3 pipeline(s). 8 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
Note
This error may be related to your runner configuration. You can now configure runners for Copilot code review separately from Copilot cloud agent by creating a copilot-code-review.yml file with your setup steps. Read the docs for details.
|
@sdkReviewAgent-2 |
This comment has been minimized.
This comment has been minimized.
|
@sdkReviewAgent-2 |
|
/azp run python - cosmos - tests |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
/azp run python - cosmos - tests |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
Note
This error may be related to your runner configuration. You can now configure runners for Copilot code review separately from Copilot cloud agent by creating a copilot-code-review.yml file with your setup steps. Read the docs for details.
|
/azp run python - cosmos - tests |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
@sdkReviewAgent-2 |
There was a problem hiding this comment.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
Note
This error may be related to your runner configuration. You can now configure runners for Copilot code review separately from Copilot cloud agent by creating a copilot-code-review.yml file with your setup steps. Read the docs for details.
|
/azp run python - cosmos - tests |
|
/azp run python - cosmos - tests |
|
@sdkReviewAgent-2 |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
🔵 Needs a closer look
The production wire format and request-body type change across both transport stacks warrant final human and API review despite strong coverage.
Review details
- Files reviewed: 26/26 changed files
- Comments generated: 0 new
- Review effort level: Balanced
|
✅ Review complete (59:51) Posted 4 inline comment(s). Steps: ✓ context, correctness, cross-sdk, design, history, past-prs, synthesis, test-coverage |
|
@sdkReviewAgent-2 |
|
/azp run python - cosmos - tests |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
🟡 Changes recommended
The unconditional PATCH header change contradicts the stated default-path compatibility guarantee.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 28/28 changed files
- Comments generated: 1
- Review effort level: Balanced
|
✅ Review complete (19:52) Posted 2 inline comment(s). Steps: ✓ context, correctness, cross-sdk, design, history, past-prs, synthesis, test-coverage |
|
/azp run python - cosmos - tests |
|
@sdkReviewAgent-2 |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
One or more custom setup steps configured for this repository failed during this Copilot code review run: Setup steps run before each review. If the review above is missing context, or no review was posted at all, the failing step above may be the cause. See the workflow run for failure details, fix your setup steps configuration, and re-request a review. Note You can configure setup steps for Copilot code review separately from Copilot cloud agent with a |
There was a problem hiding this comment.
🟢 Approval recommended
The option is correctly scoped and validated, with comprehensive sync, async, transport, resilience, and live coverage.
Review details
- Files reviewed: 28/28 changed files
- Comments generated: 0 new
- Review effort level: Balanced
[Pilot] PR Pipeline Failure AnalysisWhat failedPipeline: Two emulator tests failed on platform
Both fail with the same assertion pattern: the mock's retry counter is Relevant pipeline outputRoot causeThis PR's diff ( Recommended next steps
|
Problem-
The Python SDK currently serializes JSON request bodies with ASCII escaping enabled. As a result, non-ASCII characters are expanded before being sent to Cosmos DB.
For example:
日 → \u65e5
A character that requires 3 bytes in UTF-8 becomes 6 bytes after escaping. The service measures the 2 MiB limit against the UTF-8 length of the JSON representation it receives, so documents containing large amounts of CJK or other non-ASCII text can exceed that limit even when their compact UTF-8 representation is well below it.
This blocked customers from ingesting otherwise valid documents.
Solution-
This change adds the following opt-in client option:
CosmosClient(
endpoint,
credential,
enable_compact_utf8_item_writes=True,
)
When enabled, item bodies for create, upsert, replace, patch, and transactional batch operations are serialized using compact UTF-8 instead of ASCII escape sequences.
The default remains False , so existing applications retain their current serialization behavior.
The implementation also:
Content-Lengthbehavior, reusing the byte length produced while validating the compact body rather than encoding the full body a second time.Customer impact-
Customers can opt in to send large Unicode-heavy documents without unnecessary \uXXXX expansion. A document whose escaped JSON exceeds the 2 MiB request size limit may remain below it when sent as compact UTF-8.
The stored item and the values returned on reads are identical either way, since both encodings describe the same JSON document; only the bytes on the wire differ.
Validation-
Added sync and async coverage for: