Pagination error same continuation token returned on last page #30337
Description
- azure-cosmos:
- 4.3.0:
- debian:11:
- 3.7:
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+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