Skip to content

Conversation

@tvaron3
Copy link
Member

@tvaron3 tvaron3 commented Nov 18, 2025

Description

This pull request addresses a bug in the Azure Cosmos SDK where passing None for certain options in methods like query_items could cause unexpected errors. The main fix involves updating utility logic to handle None values 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 to None.

Bug Fixes and Logic Improvements

  • Updated the valid_key_value_exist function in _utils.py to remove keys with None values from kwargs, preventing them from causing errors in downstream logic.
  • Documented the bug fix in the CHANGELOG.md to inform users about the resolution of issues when passing None for options in query_items.

Testing Enhancements

  • Added a new test suite test_none_options.py for sync clients to verify that all container methods handle None options without error. This covers item creation, reading, updating, deleting, batch operations, and change feed queries.
  • Added a new test suite test_none_options_async.py for async clients, mirroring the sync tests to ensure consistent behavior with None options in all relevant container methods.

Miscellaneous

  • Minor cleanup in run_workloads.sh by removing an unnecessary wait statement making it more convenient to run.

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.

@tvaron3
Copy link
Member Author

tvaron3 commented Nov 18, 2025

/azp run python - cosmos - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@tvaron3
Copy link
Member Author

tvaron3 commented Nov 18, 2025

/azp run python - cosmos - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@tvaron3 tvaron3 marked this pull request as ready for review November 19, 2025 01:05
@tvaron3 tvaron3 requested a review from a team as a code owner November 19, 2025 01:05
Copilot AI review requested due to automatic review settings November 19, 2025 01:05
Copilot finished reviewing on behalf of tvaron3 November 19, 2025 01:08
Copy link
Contributor

Copilot AI left a 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 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_exist function to handle and remove None values from kwargs
  • Added comprehensive test suites for sync and async clients to verify all container methods handle None options 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

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@tvaron3 tvaron3 merged commit 845f573 into Azure:main Nov 24, 2025
21 checks passed
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants