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

オープン 初心者向け
#976 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@sebxt がすでに取り組んでいます。

2026年10月19日 から。

  • #977 @sebxt による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
82/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
api

調査の方向性

twilio/base/token_pagination.pyを読み、_get_page_async()を調べてから、issueの説明に従ってPage.next_page_async()と比較してください。現在version.pageをモックしている非同期ページネーションの単体テストを確認してください。非同期ページネーションが非同期のページメソッドをawaitし、複数ページのコレクションがAsyncTwilioHttpClientで動作すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Python
スター
2.1k
フォーク
821
平均マージ
9時間 33分
マージ済み PR(30日)
3

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

twilio/twilio-python のほかの issue

twilio/twilio-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。