Skip to content

fix: fix copilot comments - enhance batch handling in CosmosDBClient and add tests for conflict scenarios#399

Merged
Roopan-Microsoft merged 1 commit intodevfrom
psl-pk-cosavmfix
Apr 8, 2026
Merged

fix: fix copilot comments - enhance batch handling in CosmosDBClient and add tests for conflict scenarios#399
Roopan-Microsoft merged 1 commit intodevfrom
psl-pk-cosavmfix

Conversation

@Pavan-Microsoft
Copy link
Copy Markdown
Contributor

Purpose

This pull request improves error handling and test coverage for batch creation and file upload in the CosmosDB integration, and fixes type consistency for file and batch IDs. The main changes include refactoring permission errors, adding comprehensive tests for batch creation edge cases, and ensuring correct UUID usage.

Error handling improvements:

  • Changed the error raised when a batch exists but belongs to a different user from CosmosResourceNotFoundError to PermissionError in create_batch, making permission issues explicit and more accurate.

Test coverage enhancements:

  • Added tests for batch creation to cover:
    • Retrying on 404 after a 409 conflict.
    • Raising PermissionError for cross-user access.
    • Raising RuntimeError when read retries are exhausted.
  • Updated test imports to include CosmosResourceNotFoundError.
  • Added assertions in tests to verify that the correct partition_key is used in batch and file queries. [1] [2]

Type consistency and bug fixes:

  • Ensured that upload_file_to_batch passes UUID objects for batch_id and file_id to add_file, fixing a potential type mismatch.

Does this introduce a breaking change?

  • Yes
  • No

Golden Path Validation

  • I have tested the primary workflows (the "golden path") to ensure they function correctly without errors.

Deployment Validation

  • I have validated the deployment process successfully and all services are running as expected with this change.

@Roopan-Microsoft Roopan-Microsoft merged commit 75e0523 into dev Apr 8, 2026
6 checks passed
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 8, 2026

🎉 This PR is included in version 1.7.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@Pavan-Microsoft Pavan-Microsoft deleted the psl-pk-cosavmfix branch April 8, 2026 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants