Skip to content

FormatException when getting IndexMetrics from responseMessage #4396

@asgoe

Description

@asgoe

We are continuously addressing and improving the SDK, if possible, make sure the problem persist in the latest SDK version.

Describe the bug
We recently started observing an exception in our test environment when running Sql queries in CosmosDb. From our logs we see that this happens after the query has been executed and we are trying to log the Index recommendations from the returned response message. We use the FeedIterator.ReadNextAsync API to run the search query. From the below call stack this seems to be happening when the index is being converted to string inside CosmosDb.

The CosmosDb ActivityId for one such search query is: 291abd2d-2d74-462e-b347-546fb0fd1bb3 (within the last one day). Account Name = onedf-andrsync-3

To Reproduce
Not sure which search query will hit this, since not all queries are hitting this issue. But we get this by calling the FeedIterator.ReadNextAsync API and then by trying to log the responseMessage.IndexMetrics
image

Expected behavior
Exception should not be hit

Actual behavior
Format exception being thrown when accessing IndexMetrics from ResponseMessage

Environment summary
SDK Version: 3.37.1, 3.38.1
OS Version (e.g. Windows, Linux, MacOSX): Windows

Additional context
Exception stack:
System.FormatException: The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.
at System.Convert.FromBase64_Decode(Char* startInputPtr, Int32 inputLength, Byte* startDestPtr, Int32 destLength)
at System.Convert.FromBase64CharPtr(Char* inputPtr, Int32 inputLength)
at System.Convert.FromBase64String(String s)
at Microsoft.Azure.Cosmos.Query.Core.Metrics.IndexUtilizationInfo.TryCreateFromDelimitedBase64String(String delimitedString, IndexUtilizationInfo& result)
at Microsoft.Azure.Cosmos.ResponseMessage.<>c__DisplayClass46_0.b__0()
at System.Lazy1.CreateValue() at System.Lazy1.LazyInitValue()
at Microsoft.Intune.CloudStorage.CosmosDb.CosmosDbQueryV32.<ExecuteNextAsync>d__12.MoveNext() <> at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() <> at Microsoft.Intune.CloudStorage.CosmosDb.Decorators.AutoOpenDecorator1.d__51.MoveNext() <> at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() <> at Microsoft.Intune.CloudStorage.CosmosDb.Decorators.MetricsAndErrorHandlingDecorator1.d__4`1.MoveNext()

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions