diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/ExceptionToCosmosException.cs b/Microsoft.Azure.Cosmos/src/Query/Core/ExceptionToCosmosException.cs index 02c1882e26..5ee4eca609 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/ExceptionToCosmosException.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/ExceptionToCosmosException.cs @@ -157,7 +157,10 @@ internal override CosmosException Visit( { return CosmosExceptionFactory.CreateBadRequestException( message: malformedChangeFeedContinuationTokenException.Message, - headers: new Headers(), + headers: new Headers() + { + SubStatusCode = Documents.SubStatusCodes.MalformedContinuationToken + }, stackTrace: malformedChangeFeedContinuationTokenException.StackTrace, innerException: malformedChangeFeedContinuationTokenException, trace: trace); diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/CosmosItemTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/CosmosItemTests.cs index 0ad71e7085..25b46d670f 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/CosmosItemTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/CosmosItemTests.cs @@ -3319,6 +3319,23 @@ await CosmosItemTests.GivenItemAsyncWhenMissingMemberHandlingIsErrorThenExpectsC id: itemIdThatWillNotExist, partitionKey: new Cosmos.PartitionKey(partitionKeyValue), cancellationToken: cancellationToken)); + } + + [TestMethod] + public async Task MalformedChangeFeedContinuationTokenSubStatusCodeTest() + { + FeedIterator badIterator = this.Container.GetChangeFeedStreamIterator( + ChangeFeedStartFrom.ContinuationToken("AMalformedContinuationToken"), + ChangeFeedMode.Incremental, + new ChangeFeedRequestOptions() + { + PageSizeHint = 100 + }); + + ResponseMessage response = await badIterator.ReadNextAsync(); + + Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode); + Assert.AreEqual(SubStatusCodes.MalformedContinuationToken, response.Headers.SubStatusCode); } private static async Task GivenItemStreamAsyncWhenMissingMemberHandlingIsErrorThenExpectsCosmosExceptionTestAsync(