TokenPagination.next_page_async() makes a sync request and fails with an async http client
Maintainer antworten meist innerhalb von 1 Tag
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 82/100
Rechercherichtung
Lies twilio/base/token_pagination.py und untersuche _get_page_async(). Vergleiche die Funktion anschließend wie im Issue beschrieben mit Page.next_page_async(). Prüfe die Unit-Tests für asynchrone Paginierung, die derzeit version.page mocken; das Ziel ist erreicht, wenn die asynchrone Paginierung auf die asynchrone Seitenmethode wartet und eine mehrseitige Sammlung mit AsyncTwilioHttpClient funktioniert.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- Python
- Sterne
- 2.1k
- Forks
- 821
- Ø Merge
- 9 Std. 33 Min.
- Gemergte PRs (30 T.)
- 3
Entwicklungsumgebung
- Enthält ein Dockerfile oder eine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus twilio/twilio-python
-
Docs: "Handling Exceptions" should mention that network errors are not `TwilioRestException`Evtl. vergeben @henricop hat das vor 13 Tagen übernommen. Offen
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 90/100
twilio/twilio-python#986 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Clearer diagnostic when an API Key SID is passed without `account_sid`Evtl. vergeben @saryeljaramany hat das vor 5 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
twilio/twilio-python#985 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
AsyncTwilioHttpClient does not JSON-serialize request bodies for application/json endpoints (sync client does) → 400 on JSON-body v2 endpointsEvtl. vergeben @Steve0x2a hat das vor 77 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
twilio/twilio-python#932 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
twilio/twilio-python#930 ·
Maintainer antworten meist innerhalb von 1 Tag
-
[BUG] AsyncTwilioHttpClient.request does not use self.timeoutEvtl. vergeben @Hashim1999164 hat das vor 96 Tagen übernommen. Offentype: bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
twilio/twilio-python#925 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in twilio/twilio-python
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 64/100
Maintainer antworten meist innerhalb von 1 Tag
-
Harden tools/pr_threads.sh: pass all printed thread fields through the deterministic sanitizerOffenarea:cli area:security enhancement priority:medium size:small
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
RonaldHensbergen/composable-data-stack#1338 ·
Maintainer antworten meist innerhalb von 1 Tag
-
area:stdlib effort:S impact:med platform:linux type:bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
Maintainer antworten meist innerhalb von 1 Tag
-
automated endpoint-dead needs-curation
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
almanac-data/climate-almanac#139 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
UKGovernmentBEIS/inspect_ai#6695 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag