Skip to content

fix: pass pagination_token from entriesResponse to the recursive call in bulk unpublish getSyncEntries #1973

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

MetodiYanev
Copy link

This PR fixes a bug in the getSyncEntries function where the recursive call to fetch additional pages of entries would always execute — even when pagination_token was null. As a result, the function would endlessly cycle through the first page of results without making progress.

@MetodiYanev MetodiYanev requested a review from a team as a code owner June 16, 2025 15:15
@@ -228,10 +228,11 @@ async function getSyncEntries(
await bulkAction(stack, entriesResponse.items, bulkUnpublish, environment, locale, apiVersion, bulkPublishLimit, false);
}

if (entriesResponse.items.length === 0) {
if (!entriesResponse.pagination_token) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MetodiYanev I have reviewed your changes — it looks good overall. Just a suggestion to update the exit condition with the latest logic:
if (entriesResponse.items.length === 0 && !entriesResponse.pagination_token)
This ensures the sync process only stops when there are truly no more items and no further pages (pagination_token).
Earlier, checking only items.length === 0 could cause premature exit even when more data was available.

CC: @netrajpatel @aman19K @AniketDev7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants