Skip to content

fix: Cosmos patch requests not using the custom serializer - #51407

Open
Kartika Prasad (pure-zero) wants to merge 2 commits into
Azure:mainfrom
pure-zero:main
Open

Kartika Prasad (pure-zero) wants to merge 2 commits into
Azure:mainfrom
pure-zero:main

Conversation

@pure-zero

Copy link
Copy Markdown

…ions when set

Fixes #51405

Description

Please add an informative description that covers that changes made by the pull request and link all relevant issues.

If an SDK is being regenerated based on a new swagger spec, a link to the pull request containing these swagger spec changes has been included above.

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

Copilot AI balanced review requested due to automatic review settings November 24, 2026 23:21
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).
29 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@github-actions github-actions Bot added Community Contribution Community members are working on the issue Cosmos customer-reported Issues that are reported by GitHub users external to the Azure organization. labels Nov 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution Kartika Prasad (@pure-zero)! We will review the pull request and get back to you soon.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The custom serializer turns numeric INCREMENT operands into objects, causing Cosmos DB to reject those patches and transactional batches; increments must retain default serialization with long and double regression coverage.

1 open issue
What changed in this PR

This PR addresses #51405 by applying the effective CosmosItemSerializer to Cosmos DB patch values across single-item, transactional batch, and bulk requests.

Changes:

  • Resolves and forwards the effective serializer when building patch payloads.
  • Adds tests for custom serialization, fallback behavior, and batch/bulk serializer propagation.
  • Documents the fix in the Cosmos SDK changelog.
File Description
sdk/​cosmos/​azure-cosmos/​src/​main/​java/​com/​azure/​cosmos/​implementation/​patch/​PatchUtil.java Resolves serializers and applies them to patch values.
sdk/​cosmos/​azure-cosmos/​src/​main/​java/​com/​azure/​cosmos/​implementation/​batch/​ItemBulkOperation.java Forwards the effective serializer for bulk patches.
sdk/​cosmos/​azure-cosmos/​src/​main/​java/​com/​azure/​cosmos/​implementation/​batch/​ItemBatchOperation.java Forwards the effective serializer for transactional batch patches.
sdk/​cosmos/​azure-cosmos/​src/​main/​java/​com/​azure/​cosmos/​implementation/​batch/​CosmosItemOperationBase.java Adds a shared patch-body serialization helper.
sdk/​cosmos/​azure-cosmos/​CHANGELOG.md Records the custom patch serialization fix.
sdk/​cosmos/​azure-cosmos-tests/​src/​test/​java/​com/​azure/​cosmos/​implementation/​patch/​PatchUnitTest.java Tests serializer selection, precedence, and fallback behavior.
sdk/​cosmos/​azure-cosmos-tests/​src/​test/​java/​com/​azure/​cosmos/​implementation/​batch/​ItemOperationPatchSerializerTest.java Tests serializer propagation for batch and bulk patches.

Review effort: Balanced

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Community Contribution Community members are working on the issue Cosmos customer-reported Issues that are reported by GitHub users external to the Azure organization.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] CosmosItemSerializer (custom item serializer) is not applied when serializing values in CosmosPatchOperations

2 participants