Expose lsn and item_lsn on ItemResponse#4176
Conversation
Add `ITEM_LSN` header and `item_lsn: Option<u64>` field to `CosmosResponseHeaders` in the driver, parsed the same way as `lsn`. Add `lsn()` and `item_lsn()` accessors on `ItemResponse<T>` in the SDK layer, following the same pattern as `etag()`, `request_charge()`, and `session_token()`. These headers are only returned on item/document operations (create, read, replace, upsert, delete). Fixes #4164 Agent-Logs-Url: https://github.com/Azure/azure-sdk-for-rust/sessions/79fa477f-d8b3-4421-87d5-cd8b86e82107 Co-authored-by: simorenoh <30335873+simorenoh@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Exposes Cosmos DB lsn and x-ms-item-lsn response headers as typed accessors on ItemResponse<T> by parsing and storing the values in the driver-layer response headers and surfacing them via SDK methods.
Changes:
- Added
x-ms-item-lsnto the driver’s known response header names and parsed it intoCosmosResponseHeaders. - Added
lsn()anditem_lsn()accessors onItemResponse<T>in the SDK layer. - Extended/added unit tests to validate both headers are surfaced when present and return
Nonewhen absent.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| sdk/cosmos/azure_data_cosmos_driver/src/models/cosmos_headers.rs | Adds ITEM_LSN header name, stores/parses item_lsn in CosmosResponseHeaders, and extends driver tests |
| sdk/cosmos/azure_data_cosmos/src/models/item_response.rs | Adds lsn() and item_lsn() accessors on ItemResponse<T> |
| sdk/cosmos/azure_data_cosmos/src/models/cosmos_response.rs | Adds unit tests validating new ItemResponse accessors for present/missing headers |
…-item-lsn-and-lsn-response-headers
…-item-lsn-and-lsn-response-headers
After PR #4159 refactored from_headers() to use a match statement, the ITEM_LSN constant and its match arm were missing. Add them so item_lsn is actually parsed. Agent-Logs-Url: https://github.com/Azure/azure-sdk-for-rust/sessions/92d9a4cd-3b32-465e-aa21-af8ef6c02508 Co-authored-by: simorenoh <30335873+simorenoh@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
/check-enforcer override |
kushagraThapar
left a comment
There was a problem hiding this comment.
Curious, do we put PR links in the changelog? Is there a separate driver / sdk changelog file?
kushagraThapar
left a comment
There was a problem hiding this comment.
LGTM, thanks @simorenoh
kushagraThapar
left a comment
There was a problem hiding this comment.
Requesting changes for the changelog update?
|
@copilot we need a changelog entry for these header additions |
Add "Features Added" entries to both azure_data_cosmos and azure_data_cosmos_driver CHANGELOGs for the new lsn() and item_lsn() accessors on ItemResponse<T> and the item_lsn field on CosmosResponseHeaders. Agent-Logs-Url: https://github.com/Azure/azure-sdk-for-rust/sessions/64e5117e-6456-4c1d-b2d4-e1e372e0efdb Co-authored-by: simorenoh <30335873+simorenoh@users.noreply.github.com>
Added changelog entries in commit |
60c6923
into
release/azure_data_cosmos-previews
Expose the
lsnandx-ms-item-lsnCosmos DB response headers as typed accessors onItemResponse<T>. These headers are only returned on item/document operations (create, read, replace, upsert, delete).Driver layer (
azure_data_cosmos_driver)ITEM_LSNtoresponse_header_namesitem_lsn: Option<u64>field toCosmosResponseHeaders, parsed infrom_headers()identical tolsnSDK layer (
azure_data_cosmos)lsn()anditem_lsn()accessors onItemResponse<T>, wired throughCosmosResponseHeaders(same pattern asetag(),request_charge(),session_token())Tests
from_headers, builder, and default tests in the driver to coveritem_lsnItemResponseaccessor tests for bothlsnanditem_lsn(present and missing)Changelog
azure_data_cosmos/CHANGELOG.mdandazure_data_cosmos_driver/CHANGELOG.md