Description
Describe the bug
Alan Zimmer's November 6, 2026 audit of com.azure:azure-cosmos:4.84.0-beta.1 reports that the ordered DISTINCT query constructor restores the previous hash into the distinct map but initializes the outgoing-token hash to null. A resumed page containing only duplicates emits an empty page whose continuation token loses the hash. Resuming that token admits a duplicate again. An uninterrupted subscription is not affected by this particular bug. Reported priority: P1.
Exception or Stack Trace
N/A; the query returns duplicate results without an exception.
To Reproduce
Reconstruct an ordered DISTINCT query at every page boundary, including a duplicate-only empty page. Resume each outgoing continuation token. The reported probe produced page sizes 1 -> 0 -> 1; the empty page emitted "lastHash":null, and the final page admitted a duplicate.
Code Snippet
No complete executable snippet supplied. Reported location: DistinctDocumentQueryExecutionContext.java:41-43 in the audited source.
Expected behavior
Continuation tokens preserve the previous distinct hash even when a resumed page produces no new values. Results remain globally distinct across reconstructed subscriptions.
Screenshots
N/A.
Setup (please complete the following information):
- OS: Not reported.
- IDE: Not reported.
- Library/Libraries:
com.azure:azure-cosmos:4.84.0-beta.1. - Java version: Not reported.
- App Server/Environment: Ordered DISTINCT query resumed at each page boundary.
- Frameworks: Not reported.
Dependency mismatch: Not indicated; dependency tree/logs were not supplied.
Additional context
Proposed fix from the audit: initialize lastHash with previousHash.
Regression coverage: reconstruct the query at every page boundary, including empty pages, and assert globally distinct results and hash preservation in emitted continuation tokens.
Evidence: Alan reproduced this using compiled current-source query components with cached supporting dependencies. No live Cosmos calls or full SDK test suite were run, and no repository files were changed. This issue tracks validation and implementation of the proposed fix, not an already-applied fix.
Information Checklist
- Bug Description Added
- Repro Steps Added
- Setup information Added
Activity