Skip to content

Expose lsn and item_lsn on ItemResponse#4176

Merged
simorenoh merged 11 commits into
release/azure_data_cosmos-previewsfrom
copilot/expose-item-lsn-and-lsn-response-headers
Apr 21, 2026
Merged

Expose lsn and item_lsn on ItemResponse#4176
simorenoh merged 11 commits into
release/azure_data_cosmos-previewsfrom
copilot/expose-item-lsn-and-lsn-response-headers

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 14, 2026

Expose the lsn and x-ms-item-lsn Cosmos DB response headers as typed accessors on ItemResponse<T>. These headers are only returned on item/document operations (create, read, replace, upsert, delete).

Driver layer (azure_data_cosmos_driver)

  • Add ITEM_LSN to response_header_names
  • Add item_lsn: Option<u64> field to CosmosResponseHeaders, parsed in from_headers() identical to lsn

SDK layer (azure_data_cosmos)

  • Add lsn() and item_lsn() accessors on ItemResponse<T>, wired through CosmosResponseHeaders (same pattern as etag(), request_charge(), session_token())
let response: ItemResponse<MyItem> = container.read_item(pk, id, None).await?;
if let Some(lsn) = response.lsn() { /* ... */ }
if let Some(item_lsn) = response.item_lsn() { /* ... */ }

Tests

  • Extended existing from_headers, builder, and default tests in the driver to cover item_lsn
  • Added ItemResponse accessor tests for both lsn and item_lsn (present and missing)

Changelog

  • Added "Features Added" entries to both azure_data_cosmos/CHANGELOG.md and azure_data_cosmos_driver/CHANGELOG.md

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>
Copilot AI changed the title [WIP] Expose itemLSN and LSN response headers in ItemResponse Expose lsn and item_lsn on ItemResponse Apr 15, 2026
Copilot AI requested a review from simorenoh April 15, 2026 00:02
@simorenoh simorenoh marked this pull request as ready for review April 15, 2026 15:04
@simorenoh simorenoh requested a review from a team as a code owner April 15, 2026 15:04
Copilot AI review requested due to automatic review settings April 15, 2026 15:04
Copy link
Copy Markdown
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

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-lsn to the driver’s known response header names and parsed it into CosmosResponseHeaders.
  • Added lsn() and item_lsn() accessors on ItemResponse<T> in the SDK layer.
  • Extended/added unit tests to validate both headers are surfaced when present and return None when 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

Comment thread sdk/cosmos/azure_data_cosmos_driver/src/models/cosmos_headers.rs Outdated
Comment thread sdk/cosmos/azure_data_cosmos_driver/src/models/cosmos_headers.rs
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>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 20, 2026

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:

  • test.documents.azure.com
    • Triggering command: /home/REDACTED/work/azure-sdk-for-rust/azure-sdk-for-rust/target/debug/deps/azure_data_cosmos-280450d51cc1572d /home/REDACTED/work/azure-sdk-for-rust/azure-sdk-for-rust/target/debug/deps/azure_data_cosmos-280450d51cc1572d /home/REDACTED/work/azure-sdk-for-rust/azure-sdk-for-rust/target/debug/build/azure_core_test-2acab9f023191eb0/build_script_build-2acab9f023191eb0.avm3d6k4mrd2rwi4i4uanfq4d.0ouaw29.rcgu.o -Wl,--as-needed -Wl,-Bstatic get/debug/deps/rustcQt5u3W/list /home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/lib/rustlib/x86_64-REDACTED-linux-gnu/lib/libpanic_unwind-4be5972b22d3a6da.rlib /home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/lib/rustlib/x86_64-REDACTED-linux-gnu/lib/libobject-2a81194c9d07bbf6.rlib t5u3W/symbols.o erive-28aea824518d2404.clap_derive.f3ed7ee1327ffbb-cgu.00.rcgu.o erive-28aea824518d2404.clap_derive.f3ed7ee1327ffbb-cgu.01.rcgu.o erive-28aea824518d2404.clap_derive.f3ed7ee1327ffbb-cgu.02.rcgu.o erive-28aea824518d2404.clap_derive.f3ed7ee1327ffbb-cgu.03.rcgu.o erive-28aea824518d2404.clap_derive.f3ed7ee1327ffbb-cgu.04.rcgu.o erive-28aea824518d2404.clap_derive.f3ed7ee1327ffbb-cgu.05.rcgu.o erive-28aea824518d2404.clap_derive.f3ed7ee1327ffbb-cgu.06.rcgu.o erive-28aea824518d2404.clap_derive.f3ed7ee1327ffbb-cgu.07.rcgu.o erive-28aea824518d2404.clap_derive.f3ed7ee1327ffbb-cgu.08.rcgu.o erive-28aea824518d2404.clap_derive.f3ed7ee1327ffbb-cgu.09.rcgu.o erive-28aea824518d2404.clap_derive.f3ed7ee1327ffbb-cgu.10.rcgu.o erive-28aea824518d2404.clap_derive.f3ed7ee1327ffbb-cgu.11.rcgu.o (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI requested a review from simorenoh April 20, 2026 18:25
@simorenoh
Copy link
Copy Markdown
Member

/check-enforcer override

Copy link
Copy Markdown
Member

@kushagraThapar kushagraThapar left a comment

Choose a reason for hiding this comment

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

Curious, do we put PR links in the changelog? Is there a separate driver / sdk changelog file?

Comment thread sdk/cosmos/azure_data_cosmos/src/models/item_response.rs Outdated
Comment thread sdk/cosmos/azure_data_cosmos/src/models/item_response.rs Outdated
Copy link
Copy Markdown
Member

@tvaron3 tvaron3 left a comment

Choose a reason for hiding this comment

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

lgtm

Comment thread sdk/cosmos/azure_data_cosmos/src/models/item_response.rs Outdated
Comment thread sdk/cosmos/azure_data_cosmos/src/models/item_response.rs Outdated
Comment thread sdk/cosmos/azure_data_cosmos/src/models/item_response.rs Outdated
Comment thread sdk/cosmos/azure_data_cosmos/src/models/item_response.rs Outdated
Copy link
Copy Markdown
Member

@kushagraThapar kushagraThapar left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @simorenoh

Copy link
Copy Markdown
Member

@kushagraThapar kushagraThapar left a comment

Choose a reason for hiding this comment

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

Requesting changes for the changelog update?

@simorenoh
Copy link
Copy Markdown
Member

@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>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 20, 2026

@copilot we need a changelog entry for these header additions

Added changelog entries in commit 79c9851 — "Features Added" entries in both azure_data_cosmos/CHANGELOG.md and azure_data_cosmos_driver/CHANGELOG.md.

Comment thread sdk/cosmos/azure_data_cosmos/CHANGELOG.md Outdated
Copilot AI requested a review from simorenoh April 20, 2026 23:55
@simorenoh simorenoh merged commit 60c6923 into release/azure_data_cosmos-previews Apr 21, 2026
13 checks passed
@simorenoh simorenoh deleted the copilot/expose-item-lsn-and-lsn-response-headers branch April 21, 2026 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cosmos: Expose itemLSN and LSN Response Headers

6 participants