Skip to content

Commit

Permalink
Fix Python Paging Infinite Issue
Browse files Browse the repository at this point in the history
Summary: This diff fixes a bug in the Python SDK for Facebook Business where the paging cursor was not properly checked for the existence of the 'next' key, which caused an infinite loop when there were no more pages to fetch. The code changes in the 'api.py' file of the SDK and the 'facebook_business/api.py' file of the codegen templates ensure that the 'after' cursor is only set if the 'next' key exists in the paging information. This should prevent the infinite loop and allow the SDK to properly handle paging in the API calls.

Reviewed By: mengxuanzhangz

Differential Revision: D53010767

fbshipit-source-id: 6588814b8fb48be213bedc4b7e304aeecdca0211
  • Loading branch information
stcheng authored and facebook-github-bot committed Jan 23, 2024
1 parent c0d3508 commit 21557b2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion facebook_business/api.py
Expand Up @@ -835,7 +835,9 @@ def load_next_page(self):
if (
'paging' in response and
'cursors' in response['paging'] and
'after' in response['paging']['cursors']
'after' in response['paging']['cursors'] and
# 'after' will always exist even if no more pages are available
'next' in response['paging']
):
self.params['after'] = response['paging']['cursors']['after']
else:
Expand Down

0 comments on commit 21557b2

Please sign in to comment.