Skip to content

Conversation

analogrelay
Copy link
Member

This PR has two changes in one, but I think it's reasonable:

  1. Fixed the Cosmos Pipeline code after Retry policy returns non-retriable response instead of error #2834 changed behavior to return all HTTP status codes as Ok. We now convert non-2xx status codes to errors in the Cosmos Pipeline
  2. Fixed Unexpected empty response body on read_item #2824 by forcing the enable_content_response_on_write flag to true when reading an item.

I needed to do 1 in order for the tests to properly start failing on errors after #2834, and then I went in to fix the bug. Otherwise a pretty straightforward change :)

@Copilot Copilot AI review requested due to automatic review settings August 8, 2025 21:25
@github-actions github-actions bot added the Cosmos The azure_cosmos crate label Aug 8, 2025
Copy link
Contributor

@Copilot 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 Cosmos Database issue #2824 by ensuring read operations return content, and addresses test failures after HTTP behavior changes in #2834. The fix prevents read operations from returning empty responses when the enable_content_response_on_write flag is disabled.

Key changes:

  • Added error handling for non-2xx HTTP status codes in the Cosmos pipeline
  • Force enable_content_response_on_write to true for read item operations
  • Updated test code to properly handle HTTP error responses

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
sdk/typespec/typespec_client_core/src/http/response.rs Added success() method to validate HTTP status codes and convert errors
sdk/cosmos/azure_data_cosmos/src/pipeline/mod.rs Implemented error handling for non-2xx responses in pipeline operations
sdk/cosmos/azure_data_cosmos/src/clients/container_client.rs Fixed read_item to force content response flag to true
sdk/cosmos/azure_data_cosmos/tests/framework/test_data/mod.rs Updated test to use new error handling pattern
sdk/cosmos/azure_data_cosmos/tests/framework/test_account.rs Updated test to use new error handling pattern

Copy link
Member

@heaths heaths left a comment

Choose a reason for hiding this comment

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

A few thoughts, but nothing blocking. Creative!

@analogrelay
Copy link
Member Author

/azp run rust - pullrequest

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@analogrelay analogrelay requested a review from heaths August 14, 2025 17:29
Copy link

github-actions bot commented Sep 9, 2025

API Change Check

APIView identified API level changes in this PR and created the following API reviews

azure_data_cosmos

@analogrelay analogrelay merged commit 7db47e1 into Azure:main Sep 18, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Cosmos The azure_cosmos crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unexpected empty response body on read_item
3 participants