Skip to content

Fix support for container.GetItemQueryIterator using Serialized FeedRange [StartEPK, EndEPK] input #5451

@ananth7592

Description

@ananth7592

Issue Description

The .NET SDK currently has a bug in how it handles Query requests with custom serialized FeedRange values that specify StartEPK and EndEPK.

When such a FeedRange overlaps only a portion of a physical partition (rather than the full partition), the SDK incorrectly maps the request to the entire physical partition.

Specifically:

For partial FeedRange inputs, the SDK is not populating the headers x-ms-start-epk and x-ms-end-epk.

Instead, it only sets x-ms-documentdb-partitionkeyrangeid (the physical partition ID), which results in broader-than-intended scoping.

This leads to incorrect query behavior where partial ranges are expanded unintentionally to the full partition.

Acceptance Criteria

The SDK must correctly honor the contract of FeedRange:

  • When a StartEPK and EndEPK are provided, the SDK must populate x-ms-start-epk and x-ms-end-epk headers accordingly.

  • Queries should be scoped only to the specified logical range, not the entire physical partition.

  • Unit and integration tests must validate that partial FeedRange queries respect the defined boundaries across different partition overlap scenarios.

  • Regression tests confirm that full partition FeedRange queries continue to behave as expected.

Code sample of the issue

      var queryDefinition = new QueryDefinition("Select * from c");
      string feedRangeSerialization = JsonConvert.SerializeObject(new 
              { Range = new { min = "0", max = "1DF48064A289030124119FB7736C62FB"} });
      FeedRange feedRange = FeedRange.FromJsonString(feedRangeSerialization);

      // Query multiple items from container
      using FeedIterator<JObject> feed = container.GetItemQueryIterator<JObject>(
          feedRange,
          queryDefinition);

        // Iterate query result pages
        while (feed.HasMoreResults)
        {
            Console.WriteLine($"ReadNextAsync");
            FeedResponse<JObject> response = await feed.ReadNextAsync();

            Console.WriteLine(response.Diagnostics.ToString());
            // Iterate query results
            foreach (JObject item in response)
            {
                Console.WriteLine(item);
            }
        }`

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions