Shopify Skipping over Orders in Cursor-based Pagination

Solved
Highlighted
Tourist
11 1 3

Hi,


So we've noticed a problem with Shopify's cursors on one our clients' stores. A client was complaining about certain orders being omitted from our app. We investigated, and sure enough, there were indeed orders missing.

We've traced the problem to an issue with Shopify's cursors. For example, when we make the following call:

https://*****************/admin/api/2019-10/orders.json?limit=250&page_info=eyJkaXJlY3Rpb24iOiJuZXh0...

We get a list of 250 orders, as expected. It gives us the following as the next link in the response headers:

https://*****************/admin/api/2019-10/orders.json?limit=250&page_info=eyJkaXJlY3Rpb24iOiJuZXh0...

This next page (the last page), returns only 170 orders, which is fine; being the terminal page.

However, between these two pages, there are 5 orders that are being completely omitted, all with the same created_at timestamp. So there's an issue here where Shopify is literally just omitting orders between cursors. The cursors look to be constructed correctly (their last_id and last_value values are correct), but they're still omitting information. This is consistently repeatable.

The orders do show up if a different created_at_min and created_at_max period is chosen, so the orders are not consistently omitted in all queries; it appears to be entirely cursor dependent.

Any Shopify devs out there able to help?

2 Likes
Highlighted
Shopify Partner
531 38 109

If you search through this forum you will see a few similar threads --> https://community.shopify.com/c/Shopify-APIs-SDKs/REST-API-Cursor-based-pagination-Infinite-Loop-quo....

I think the Shopify API cursor-based pagination is just looking at timestamps and not taking unique record ID's into account in order to provide the full result set. Either they need to drop the timestamp down to milliseconds to pull unique records or else also link record ID's to provide good referential integrity. So far I haven't seen any Shopify dev staff respond to the other threads.    

3 Likes
Highlighted
Tourist
11 1 3

Yeah. They're all set up for it with the cursors recording the last relevant ID, but it's like they're just not using it when you feed that info back in. Weird.

1 Like
Highlighted
Tourist
5 0 3

This also happened to us. Has there been a fix issued? It looks like cursors that we were seeing a couple of weeks ago are different than what they are now and they include the fractional seconds.

0 Likes
Highlighted
Tourist
11 1 3

This is an accepted solution.

This has been fixed, yes.

0 Likes