-
Notifications
You must be signed in to change notification settings - Fork 299
Labels
CosmosThe azure_cosmos crateThe azure_cosmos crateblocking-releaseBlocks releaseBlocks releasebugThis issue requires a change to an existing behavior in the product in order to be resolved.This issue requires a change to an existing behavior in the product in order to be resolved.customer-reportedIssues that are reported by GitHub users external to the Azure organization.Issues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamWorkflow: This issue needs attention from Azure service team or SDK team
Description
Bug Title
Unexpected empty response body on read_item
Crate Name
azure_data_cosmos
Crate Version
0.25.0
Description
In the documentation it is mentioned that the read item is always returned and the enable_content_response_on_write
is ignored.
However, unless I set enable_content_response_on_write
, the response body is empty and response.into_body().await.unwrap()
fails with Error { context: Custom(Custom { kind: DataConversion, error: Error("EOF while parsing a value", line: 1, column: 0) }) }
because the response body is empty.
Steps to Reproduce
Follow the CRUD operations example from the docs
use serde::{Serialize, Deserialize};
use azure_data_cosmos::{CosmosClient, models::PatchDocument};
#[derive(Serialize, Deserialize)]
struct Item {
pub id: String,
pub partition_key: String,
pub value: String,
}
async fn example(cosmos_client: CosmosClient) -> Result<(), Box<dyn std::error::Error>> {
let item = Item {
id: "1".into(),
partition_key: "partition1".into(),
value: "2".into(),
};
let container = cosmos_client.database_client("myDatabase").container_client("myContainer");
// Create an item
container.create_item("partition1", item, None).await?;
// Read an item
let item_response = container.read_item("partition1", "1", None).await?;
let item: Item = item_response.into_body().await?; // This will fail as the response body is empty
Ok(())
}
Setting the enable_content_response_on_write
option makes it respond with the expected item.
// Read an item
let mut options = ItemOptions::default();
options.enable_content_response_on_write = true;
let item_response = container.read_item("partition1", "1", Some(options)).await?;
let item: Item = item_response.into_body().await?;
Checklist
- Follow our Code of Conduct
- Check that there isn't already an issue that request the same bug to avoid creating a duplicate.
- The provided reproduction is a minimal reproducible example of the bug.
Metadata
Metadata
Assignees
Labels
CosmosThe azure_cosmos crateThe azure_cosmos crateblocking-releaseBlocks releaseBlocks releasebugThis issue requires a change to an existing behavior in the product in order to be resolved.This issue requires a change to an existing behavior in the product in order to be resolved.customer-reportedIssues that are reported by GitHub users external to the Azure organization.Issues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamWorkflow: This issue needs attention from Azure service team or SDK team