-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[Cosmos] Etag handling bugfix and documentation rollback #40282
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses a bug in etag handling by reworking how etag and match_condition are propagated in the SDK and updating corresponding tests, while reverting documentation changes for the upsert_item methods.
- Updated tests to now pass etag as None instead of a random string.
- Enhanced the upsert_item API in both synchronous and asynchronous container implementations to correctly accept etag and match_condition parameters.
- Modified _base.py to raise a ValueError when an etag is provided without a corresponding match_condition, ensuring proper error handling.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
sdk/cosmos/azure-cosmos/tests/test_backwards_compatibility_async.py | Updated test scenarios for asynchronous etag handling by passing etag as None. |
sdk/cosmos/azure-cosmos/tests/test_backwards_compatibility.py | Updated test scenarios for synchronous etag handling by passing etag as None. |
sdk/cosmos/azure-cosmos/azure/cosmos/container.py | Modified upsert_item to accept and forward etag and match_condition parameters. |
sdk/cosmos/azure-cosmos/azure/cosmos/aio/_container.py | Modified async upsert_item to accept and forward etag and match_condition parameters. |
sdk/cosmos/azure-cosmos/azure/cosmos/_base.py | Changed error handling to raise an exception if etag is provided without match_condition. |
sdk/cosmos/azure-cosmos/CHANGELOG.md | Documented the etag bug fix in the changelog. |
API change check APIView has identified API level changes in this PR and created following API reviews. |
This reverts commit ce4dbad.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good, though I am curious, are there any more test cases that we need to think about? Or does this cover everything related to _etag and match_condition?
It's the one case we didn't cover for the relevant code paths - unfortunately our logic in |
The
etag
handling that was changed as part of PR 40008 missed the fact that there was improper handling for this argument in the _base.py class that would now take care of this logic. This PR aims at improving that logic based on these new changes. Specifically, an exception would be raised when manually providing 'None' for anetag
value as an argument.This PR also reverts changes to the etag and match_conditions documentation for the upsert_item methods in their respective clients, since upsert, replace and delete are all valid for these options.