TokenPagination.next_page_async() makes a sync request and fails with an async http client
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 82/100
Hướng nghiên cứu
Đọc twilio/base/token_pagination.py và kiểm tra _get_page_async(), sau đó so sánh với Page.next_page_async() như mô tả trong issue. Kiểm tra các bài kiểm thử đơn vị về phân trang bất đồng bộ, hiện đang mock version.page; hoàn thành khi phân trang bất đồng bộ chờ phương thức trang bất đồng bộ và một collection nhiều trang hoạt động với AsyncTwilioHttpClient.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Python
- Star
- 2.1k
- Fork
- 821
- Merge trung bình
- 9 giờ 33 phút
- Pull request đã merge (30 ngày)
- 3
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của twilio/twilio-python
-
Docs: "Handling Exceptions" should mention that network errors are not `TwilioRestException`Có thể đã có người làm @henricop đã nhận 13 ngày trước. Đang mở
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 90/100
twilio/twilio-python#986 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Clearer diagnostic when an API Key SID is passed without `account_sid`Có thể đã có người làm @saryeljaramany đã nhận 5 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
twilio/twilio-python#985 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
AsyncTwilioHttpClient does not JSON-serialize request bodies for application/json endpoints (sync client does) → 400 on JSON-body v2 endpointsCó thể đã có người làm @Steve0x2a đã nhận 77 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
twilio/twilio-python#932 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
twilio/twilio-python#930 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG] AsyncTwilioHttpClient.request does not use self.timeoutCó thể đã có người làm @Hashim1999164 đã nhận 96 ngày trước. Đang mởtype: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
twilio/twilio-python#925 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của twilio/twilio-python
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Harden tools/pr_threads.sh: pass all printed thread fields through the deterministic sanitizerĐang mởarea:cli area:security enhancement priority:medium size:small
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
RonaldHensbergen/composable-data-stack#1338 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area:stdlib effort:S impact:med platform:linux type:bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày
-
automated endpoint-dead needs-curation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
almanac-data/climate-almanac#139 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
UKGovernmentBEIS/inspect_ai#6695 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày