Azure / azure-sdk-for-python

This repository is for active development of the Azure SDK for Python. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/python/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-python.
MIT License
4.53k stars 2.76k forks source link

Pagination error same continuation token returned on last page #30337

Open pierre-at-work opened 1 year ago

pierre-at-work commented 1 year ago

Describe the bug I use the pager of query_items results and when the pagination reach the last page the continuation token returned is the same as the continuation token provided as parameter to the by_page method. So the code enter in a infinite loop of pagination without returning the continuation token that indicate that the pagination process comes to the end (an empty string). The query used is something like that: SELECT * FROM r WHERE r.type='foo' ORDER BY bar ASC

To Reproduce I can't reproduce the bug on demand but it appends sometimes My code looks like something like that

query = " SELECT * FROM r WHERE r.type='foo' ORDER BY bar ASC"

found_items = cosmosdb_container.query_items(
    query, parameters, partition_key=user_id, max_item_count=max_result
)
pager = found_items.by_page(continuation_token)

try:
    items = pager.next()
except StopIteration:
    items = []

Expected behavior When the pager reach the last page the continuation token returned is an empty string

Additional context This is a continuation token that is returned as loop in the last page by the package :

+RID:~mNZSAL9hNJvyMWQBAAAABg==#RT:8#TRC:800#RTD:HPJJmKT1uZqlBBnGyNSOBMHZi39F0A==#ISV:2#IEO:65567#QCF:9#FPC:Agh8BQAAABgAAKEFAAAAIAAAfAUAAAAYAAAKAGEAABihGeAAGJB9BQAAABgAAAIAdb1+BQAAABgAAAgAy4Eik8EZ4AB/BQAAABgAAAYAxpqBiEmAgAUAAAAYAAAIACEDAwBxPDAAgQUAAAAYAAAIAMEgAAwakLWNgwUAAAAYAAAKAG2IyYGZgKSL8KiEBQAAABgAAAIA0rSFBQAAABgAAAQAhY4FjYYFAAAAGAAABgBdmzEhgAGHBQAAABgAAAYAxJNxJgBgiQUAAAAYAAAGAPeDESzwAYsFAAAAGAAABgCZjjyboouMBQAAABgAAAgAZIGggsE3gAOOBQAAABgAAAYApIrxEMADkAUAAAAYAAAGAOIxAP4HABAFAAAAIAAAEgABPfz/kUD/4xFA/z/xAQD+MEARBQAAACAAAAoAEUEfALIlAP//ARYFAAAAIAAABgCSHwDA/wAYBQAAACAAABgAkSvAHxmAaIK2gFWAnIURgRWAOYDBBwUAGQUAAAAgAAAIAF6AoR5wAHaOGgUAAAAgAAAOAD+jAcADAHqNPYBBiniBGwUAAAAgAAAKACSJPYBoiliov4McBQAAACAAAAQA8SIGAB0FAAAAIAAABgARDwAGF5EfBQAAACAAAAIAmbggBQAAACAAAAQAgSUAAyEFAAAAIAAABADhIAAHIgUAAAAgAAAKANEMAMD0iOESgAEjBQAAACAAAAQAcRcADiUFAAAAIAAADgAhGfAfQRYAwF+DAcADAC4FAAAAIAAACADSI8D/AwCLki8FAAAAIAAACACslEqAUSoADjAFAAAAIAAABAAdqieFMQUAAAAgAAAKAFECDADhGQA48aEyBQAAACAAAAYA0osbgQqbMwUAAAAgAAAMANiJfoiOg1KEMRYAGDQFAAAAIAAABgC4kbGTgY41BQAAACAAAAoAsQoAcAygw440hjYFAAAAIAAADAArglSAAoAug6uRbYc3BQAAACAAAAQAspbggjgFAAAAIAAABgD+gWExABg5BQAAACAAAAoA14Ptig2khIskgDoFAAAAIAAABgDJgZaJQ4U7BQAAACAAAAQAMQdgADwFAAAAIAAABAAhMTAASgUAAAAgAAACAJ25WAUAAAAgAAAEACEwAAN/BQAAACAAAAQAsSHAB4EFAAAAIAAAAgAisIcFAAAAIAAABABhAwMAiQUAAAAgAAAEALqeDISLBQAAACAAAAQA5o6bk40FAAAAIAAABAChj0yNjgUAAAAgAAACAFyklQUAAAAgAAAEAFEMwAOXBQAAACAAAAIAObuYBQAAACAAAAIACaWZBQAAACAAAAIATpiaBQAAACAAAAIAX5abBQAAACAAAA4Ar4IpmrSIEoUrgWyB4oicBQAAACAAAAwAGJm/nTKAmYDmgYqEngUAAAAgAAACAImEnwUAAAAgAAACAL+ioAUAAAAgAAAEAKEWcAChBQAAACAAAAIAmKU=
kashifkhan commented 1 year ago

Thank you for the feedback @pierre-at-work . We will investigate and get back to you asap.

github-actions[bot] commented 1 year ago

Thank you for your feedback. This has been routed to the support team for assistance.

github-actions[bot] commented 1 year ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @pjohari-ms @simorenoh @gahl-levy @bambriz.