TokenPagination.next_page_async() makes a sync request and fails with an async http client
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 82/100
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
- Incluye un Dockerfile o un archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de twilio/twilio-python
-
Docs: "Handling Exceptions" should mention that network errors are not `TwilioRestException`Posiblemente ocupada @henricop la tomó hace 13 días. Abierto
Dificultad 1/5 1-3 horas Aptitud para principiantes 90/100
twilio/twilio-python#986 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Clearer diagnostic when an API Key SID is passed without `account_sid`Posiblemente ocupada @saryeljaramany la tomó hace 5 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
twilio/twilio-python#985 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
AsyncTwilioHttpClient does not JSON-serialize request bodies for application/json endpoints (sync client does) → 400 on JSON-body v2 endpointsPosiblemente ocupada @Steve0x2a la tomó hace 77 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
twilio/twilio-python#932 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
twilio/twilio-python#930 ·
Los mantenedores suelen responder en 1 día
-
[BUG] AsyncTwilioHttpClient.request does not use self.timeoutPosiblemente ocupada @Hashim1999164 la tomó hace 96 días. Abiertotype: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
twilio/twilio-python#925 ·
Los mantenedores suelen responder en 1 día
Todos los issues de twilio/twilio-python
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
Los mantenedores suelen responder en 1 día
-
Harden tools/pr_threads.sh: pass all printed thread fields through the deterministic sanitizerAbiertoarea:cli area:security enhancement priority:medium size:small
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
RonaldHensbergen/composable-data-stack#1338 ·
Los mantenedores suelen responder en 1 día
-
area:stdlib effort:S impact:med platform:linux type:bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Los mantenedores suelen responder en 1 día
-
automated endpoint-dead needs-curation
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
almanac-data/climate-almanac#139 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
UKGovernmentBEIS/inspect_ai#6695 · 1 comentario ·
Los mantenedores suelen responder en 1 día