diff --git a/pkg/plugin/sift_api_queries.go b/pkg/plugin/sift_api_queries.go index 47e77d1..61fcaa0 100644 --- a/pkg/plugin/sift_api_queries.go +++ b/pkg/plugin/sift_api_queries.go @@ -194,9 +194,13 @@ func handlePaginatedRequest[T any]( results = append(results, items...) - // If there's no next page nextPageToken, break out of the loop. if nextPageToken == "" { + // If there's no nextPageToken, break out of the loop. break + } else if i == maxPages-1 { + // If there is a nextPageToken but we've already hit our maxPages + // limit, return an error. + return nil, fmt.Errorf("query generated too many pages (>%d) of results, data has been dropped", maxPages) } params.Set("page_token", nextPageToken) }