Skip to content

Fix VerifySessionNotFoundStatistics test for exception-less 404/1002 responses#5563

Closed
Copilot wants to merge 4 commits intousers/kirankk/enable_exception_lessfrom
copilot/sub-pr-5205-again
Closed

Fix VerifySessionNotFoundStatistics test for exception-less 404/1002 responses#5563
Copilot wants to merge 4 commits intousers/kirankk/enable_exception_lessfrom
copilot/sub-pr-5205-again

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 15, 2026

The VerifySessionNotFoundStatistics test expects ReadItemAsync<T> to throw CosmosException for session-not-found errors (404/1002), but exception-less behavior is now enabled by default.

Changes

  • CosmosItemTests.cs: Updated test to validate response status codes instead of catching exceptions
    • Assert HttpStatusCode.NotFound and SubStatusCodes.ReadSessionNotAvailable on response
    • Verify diagnostics contain "Point Operation Statistics"
    • Removed try-catch block expecting exception

Before (exception-based):

try {
    await container.ReadItemAsync<ToDoActivity>(id, pk, 
        new ItemRequestOptions() { SessionToken = staleToken });
    Assert.Fail("Should have thrown");
} catch (CosmosException ex) {
    Assert.AreEqual(StatusCodes.NotFound, ex.StatusCode);
    // ...
}

After (exception-less):

var response = await container.ReadItemAsync<ToDoActivity>(id, pk,
    new ItemRequestOptions() { SessionToken = staleToken });
    
Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode);
Assert.AreEqual(SubStatusCodes.ReadSessionNotAvailable, response.Headers.SubStatusCode);
Assert.IsTrue(response.Diagnostics.ToString().Contains("Point Operation Statistics"));

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits January 15, 2026 19:18
…behavior

Co-authored-by: kirankumarkolli <6880899+kirankumarkolli@users.noreply.github.com>
Co-authored-by: kirankumarkolli <6880899+kirankumarkolli@users.noreply.github.com>
Co-authored-by: kirankumarkolli <6880899+kirankumarkolli@users.noreply.github.com>
Copilot AI changed the title [WIP] Update to address feedback on exceptionless status codes Fix VerifySessionNotFoundStatistics test for exception-less 404/1002 responses Jan 15, 2026
Copilot AI requested a review from kirankumarkolli January 15, 2026 19:24
@kirankumarkolli
Copy link
Copy Markdown
Member

Duplicate of #5756

@kirankumarkolli kirankumarkolli marked this as a duplicate of #5756 Apr 11, 2026
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.

2 participants