None Options for Container APIs#44098
Merged
tvaron3 merged 16 commits intoAzure:mainfrom Nov 24, 2025
Merged
Conversation
…into tvaron3/noneOptions
Member
Author
|
/azp run python - cosmos - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Member
Author
|
/azp run python - cosmos - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a bug where passing None values for optional parameters in Azure Cosmos SDK container operations would cause unexpected errors. The fix updates the valid_key_value_exist utility function to remove keys with None values from kwargs before processing, and adds comprehensive test coverage for both sync and async clients.
Key Changes:
- Modified
valid_key_value_existfunction to handle and removeNonevalues from kwargs - Added comprehensive test suites for sync and async clients to verify all container methods handle
Noneoptions correctly - Updated CHANGELOG to document the bug fix
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/cosmos/azure-cosmos/azure/cosmos/_utils.py | Updated valid_key_value_exist to remove keys with None values, preventing downstream errors |
| sdk/cosmos/azure-cosmos/tests/test_none_options.py | Added comprehensive sync test suite validating container operations with None parameters |
| sdk/cosmos/azure-cosmos/tests/test_none_options_async.py | Added comprehensive async test suite validating container operations with None parameters |
| sdk/cosmos/azure-cosmos/CHANGELOG.md | Documented the bug fix for None option handling |
| sdk/cosmos/azure-cosmos/tests/workloads/run_workloads.sh | Removed wait statement to allow script to exit after starting workloads |
simorenoh
approved these changes
Nov 24, 2025
msyyc
pushed a commit
that referenced
this pull request
Nov 25, 2025
* change workloads based on feedback * add staging yml file * add staging yml file * test_none_options * test_none_options * update changelog * revert unrelated file * react to copilot comments
simorenoh
pushed a commit
that referenced
this pull request
Dec 2, 2025
* change workloads based on feedback * add staging yml file * add staging yml file * test_none_options * test_none_options * update changelog * revert unrelated file * react to copilot comments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This pull request addresses a bug in the Azure Cosmos SDK where passing
Nonefor certain options in methods likequery_itemscould cause unexpected errors. The main fix involves updating utility logic to handleNonevalues gracefully, and comprehensive new tests have been added for both sync and async clients to ensure all container operations work correctly when optional parameters are set toNone.Bug Fixes and Logic Improvements
valid_key_value_existfunction in_utils.pyto remove keys withNonevalues fromkwargs, preventing them from causing errors in downstream logic.CHANGELOG.mdto inform users about the resolution of issues when passingNonefor options inquery_items.Testing Enhancements
test_none_options.pyfor sync clients to verify that all container methods handleNoneoptions without error. This covers item creation, reading, updating, deleting, batch operations, and change feed queries.test_none_options_async.pyfor async clients, mirroring the sync tests to ensure consistent behavior withNoneoptions in all relevant container methods.Miscellaneous
run_workloads.shby removing an unnecessarywaitstatement making it more convenient to run.All SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines