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

Ouverte Adaptée aux débutants
#976 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

@sebxt y travaille déjà.

Depuis le 19/10/2026.

  • #977 par @sebxt — ouverte

Évaluation

Difficulté
2/5
Temps estimé
1-3 heures
Accessibilité débutants
82/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
python
Domaine
api

Piste de recherche

Lisez twilio/base/token_pagination.py et examinez _get_page_async(), puis comparez-le à Page.next_page_async() comme indiqué dans l’issue. Vérifiez les tests unitaires de pagination asynchrone, qui simulent actuellement version.page ; le travail est terminé lorsque la pagination asynchrone attend la méthode de page asynchrone et qu’une collection de plusieurs pages fonctionne avec AsyncTwilioHttpClient.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

What happens

TokenPagination._get_page_async() (used by next_page_async() and previous_page_async()) calls the synchronous self._version.page(...) instead of awaiting self._version.page_async(...).

With AsyncTwilioHttpClient, the sync path calls http_client.request(...), which is a coroutine function, so the page constructor receives an unawaited coroutine and raises:

AttributeError: 'coroutine' object has no attribute 'status_code'

This breaks stream_async() / list_async() for every resource that uses token pagination (for example memory.v1 stores, profiles, traits, observations and insights.v3 query jobs) as soon as a second page is needed. The first page loads, then iteration crashes. Python also warns that the coroutine was never awaited.

What should happen

The async helper should await self._version.page_async(...), the same way Page.next_page_async() awaits request_async.

Minimal repro

import asyncio
from twilio.http.async_http_client import AsyncTwilioHttpClient
from twilio.rest import Client

async def main():
    client = Client(account_sid, auth_token, http_client=AsyncTwilioHttpClient())
    async for store in await client.memory.v1.stores.stream_async(page_size=1):
        print(store)

asyncio.run(main())

Any collection with more than one page fails after the first page.

Root cause

twilio/base/token_pagination.py, _get_page_async():

response = self._version.page(method="GET", uri=self._uri, params=self._params)

The existing async unit tests mock version.page (the sync method), so they pass even though the real async client path is broken.

Langage dominant
Python
Étoiles
2.1k
Forks
821
Merge moyen
9 h 33 min
PR mergées (30 j)
3

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de twilio/twilio-python

Toutes les issues de twilio/twilio-python

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.