Python SDK analytics export hitting S3 with boto3, pagination breaks on large datasets

Here’s the rough loop structure we’re running to pull queue metrics:

next_page = None
while True:
 response = client.analytics.get_analytics_queue_metrics(
 body=query,
 page_size=5000
 )
 csv_writer.writerow(response.entities)
 next_page = response.next_page_id
 if not next_page:
 break

The S3 upload part is straightforward, just a simple boto3.client('s3').put_object call once the CSV buffer fills up. The initial fetch works fine, but the pagination logic completely falls apart once the dataset crosses the 10k row mark. We’re using the Genesys Cloud Python SDK for this daily export job, and it keeps returning None for next_page_id even when there’s clearly more data. The API drops the nextPageId field after the third cycle. It’s weird because the raw HTTP response actually contains the token, but the Python model parser strips it out. We’ve tried adjusting the page_size to 2500 and added a 200ms sleep between requests, but the value still vanishes. Rate limiting headers look clean. Logs show a 200 OK every time.