Azure / azure-cosmos-dotnet-v3

.NET SDK for Azure Cosmos DB for the core SQL API
MIT License
723 stars 477 forks source link

[Internal] Query : Fixes response parsing error for ReadFeed by limiting binary format to query operations #4515

Closed adityasa closed 1 month ago

adityasa commented 1 month ago

Pull Request Template

Description

This change restricts use of SupportedSerializationFormats header to query scenarios only. Technically, this header is only used by QueryRequestOptions, however, the QueryRequestOptions (and therefore this header) also get invoked for ReadFeed. There is no direct API for ReadFeed, instead any of the query APIs (GetItemLinqQueryable, GetItemQueryIterator, GetItemStreamQueryIterator) invoke ReadFeed operation (instead of Query operation) if supplied query (or QueryDefinition) is null.

ReadFeed API in the backend currently doesn't support this header and returns the response in text. However as it turns out, if this API is invoked with a specific partition key in the request options, backend honors the header. This is an issue, since SDK doesn't support handling of binary response in ReadFeed codepath.

As a result, when query APIs are invoked with query = null and a specific partition key, response cannot be parsed successfully. The issue is recently discovered after new emulator is published, which enabled binary encoding by default (when /EnablePreview flag is supplied). The issue was discovered in the form of test failures in the pipeline (which uses latest emulator with EnablePreview flag). Currently following tests are failing: EncryptionCreateItemAndQuery ValidateSupportedSerializationFormatsRntbd ValidateSupportedSerializationFormatsGateway

This change fixes following tests: ValidateSupportedSerializationFormatsRntbd ValidateSupportedSerializationFormatsGateway

The encryption project does not use the SDK code from master (by referencing project), but rather released SDK v3.35.4. The failing portion of the EncryptionCreateItemAndQuery test is made conditional, by only allowing to run when SDK project is referenced.

Type of change

Please delete options that are not relevant.

Closing issues

To automatically close an issue: closes #IssueNumber