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

Aberta Para iniciantes
#976 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

@sebxt já está trabalhando nisso.

Desde 19/10/2026.

  • #977 de @sebxt — aberto

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
82/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
python
Domínio
api

Direção de pesquisa

Leia twilio/base/token_pagination.py e inspecione _get_page_async(). Em seguida, compare com Page.next_page_async() conforme descrito na issue. Confira os testes unitários de paginação assíncrona, que atualmente usam um mock de version.page; o trabalho estará concluído quando a paginação assíncrona aguardar o método assíncrono da página e uma coleção com várias páginas funcionar com AsyncTwilioHttpClient.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.

Linguagem predominante
Python
Estrelas
2.1k
Forks
821
Merge médio
9h 33min
PRs com merge (30d)
3

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de twilio/twilio-python

Todas as issues de twilio/twilio-python

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.