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

Abierto Apto para principiantes
#976 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@sebxt ya está trabajando en esto.

Desde el 19/10/2026.

  • #977 de @sebxt — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
82/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python
Área
api

Línea de trabajo

Lee twilio/base/token_pagination.py e inspecciona _get_page_async(). Después, compáralo con Page.next_page_async() tal como se describe en el issue. Revisa las pruebas unitarias de paginación asíncrona, que actualmente usan un mock de version.page; se considera terminado cuando la paginación asíncrona espera al método asíncrono de página y una colección de varias páginas funciona con AsyncTwilioHttpClient.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Python
Estrellas
2.1k
Forks
821
Merge medio
9 h 33 min
PR fusionados (30 d)
3

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de twilio/twilio-python

Todos los issues de twilio/twilio-python

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.