Skip to content

fix: await page_async in TokenPagination async navigation - #977

Open
sebxt wants to merge 1 commit into
twilio:mainfrom
sebxt:fix/token-pagination-async-uses-sync-request
Open

sebxt wants to merge 1 commit into
twilio:mainfrom
sebxt:fix/token-pagination-async-uses-sync-request

Conversation

@sebxt

@sebxt sebxt commented Oct 19, 2026

Copy link
Copy Markdown

Fixes

TokenPagination._get_page_async() called the synchronous Version.page(). With an async http client that returns an unawaited coroutine, so next_page_async(), previous_page_async() and stream_async() on token paginated resources failed on the second page with AttributeError: 'coroutine' object has no attribute 'status_code'.

This change awaits Version.page_async() instead.

Tests:

  • Added TokenPaginationAsyncStreamTest, which drives next_page_async() and Version.stream_async() through AsyncHolodeck. Both fail on main and pass with the fix.
  • Updated TokenPaginationAsyncTest to mock page_async with AsyncMock, since those tests previously mocked the sync page method and asserted the buggy call.

pytest tests --ignore=tests/cluster: 643 passed.

Checklist

  • I acknowledge that all my contributions will be made under the project's license
  • I have made a material change to the repo (functionality, testing, spelling, grammar)
  • I have read the Contribution Guidelines and my PR follows them
  • I have titled the PR appropriately
  • I have updated my branch with the main branch
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation about the functionality in the appropriate .md file
  • I have added inline documentation to the code I modified

Fixes #976

Signed-off-by: Sebastian Turner <sebastiant3484@gmail.com>

This branch has not been deployed

No deployments
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.

TokenPagination.next_page_async() makes a sync request and fails with an async http client

1 participant