Skip to content

[Cosmos] Validate ReadConsistencyStrategy header propagation in thin client mode (#48094)#48787

Draft
jeet1995 wants to merge 2 commits intoAzure:mainfrom
jeet1995:squad/48094-readconsistency-header-propagation
Draft

[Cosmos] Validate ReadConsistencyStrategy header propagation in thin client mode (#48094)#48787
jeet1995 wants to merge 2 commits intoAzure:mainfrom
jeet1995:squad/48094-readconsistency-header-propagation

Conversation

@jeet1995
Copy link
Copy Markdown
Member

Issue

Fixes #48094

Problem

ReadConsistencyStrategy HTTP header (x-ms-cosmos-read-consistency-strategy) was silently dropped in thin client mode because no RNTBD header constant existed for it. The thin client proxy reads RNTBD headers, not HTTP headers — so the strategy was never propagated through the proxy to the backend.

Fix

  1. Added RNTBD header constant ReadConsistencyStrategy (ID 0x00F0, String type) in RntbdConstants.java
  2. Added encoding logic in RntbdRequestHeaders to serialize the strategy value into the RNTBD header
  3. Ensures the thin client proxy can read and forward the consistency strategy to the backend

Coordination Required

RNTBD header ID 0x00F0 should be coordinated with the proxy/service team to avoid ID collisions.

Testing

  • 10 new unit tests covering all ReadConsistencyStrategy values in both Direct and thin-client encoding modes
  • Build and all tests pass

…n modes (Azure#48094)

- Add ReadConsistencyStrategy RNTBD header (0x00F0, String) to RntbdConstants
  and RntbdRequestHeaders for thin client proxy propagation
- Replace Gateway-mode warn+ignore with client-side GLOBAL_STRONG validation
  that works across all modes (direct, gateway, thin client)
- Update ReadConsistencyStrategy javadoc to reflect all-modes support
- Add unit tests for RNTBD token encoding and round-trip
- Add E2E tests for thin client and compute gateway ReadConsistencyStrategy

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jeet1995 jeet1995 force-pushed the squad/48094-readconsistency-header-propagation branch from a3d4c0f to 26648a7 Compare April 16, 2026 00:36
…is set (Azure#48094)

RxGatewayStoreModel.applySessionToken() called RequestHelper.getReadConsistencyStrategyToUse()
which had a side-effect of rewriting x-ms-consistency-level header (e.g., LATEST_COMMITTED
mapped to BoundedStaleness). The compute gateway rejected this because BoundedStaleness is
stricter than the Session account default.

Fix: Use a copy of the headers map so the original x-ms-consistency-level is preserved.
Gateway/proxy now sees:
- x-ms-consistency-level: Session (original, unchanged)
- x-ms-cosmos-read-consistency-strategy: LatestCommitted (RCS intent)

Verified E2E: LATEST_COMMITTED, EVENTUAL, SESSION, client-level RCS all return 200.
GLOBAL_STRONG correctly throws BadRequestException on Session account.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

[FEATURE REQ] [Thin Client] Validate ReadConsistencyStrategy header propagation in thin client mode

1 participant