int(retry_after) raises ValueError on a non-integer Retry-After value
Chưa có ai nhận issue nà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
- 78/100
Hướng nghiên cứu
Bắt đầu trong shopify_app/graphql/admin_graphql.py, tại các trình xử lý retry đồng bộ và bất đồng bộ của admin_graphql_request quanh dòng 398 và 454. Theo dõi cách Retry-After được lấy, sau đó xác minh rằng các giá trị thập phân hoặc không hợp lệ không còn thoát ra dưới dạng ValueError và cả hai trình xử lý vẫn tiếp tục với hành vi retry hoặc GQLResult của chúng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
The 429 retry handlers in admin_graphql_request coerce Retry-After with int(), which raises ValueError on any value that is not a bare integer. HTTP permits a decimal seconds value as well as an HTTP-date, and decimal values are what Shopify's own rate-limited REST responses carry.
The exception is uncaught, so it propagates out of admin_graphql_request instead of being retried or returned as a GQLResult.
Version: shopifyapp 1.0.1 (sdist from PyPI).
Cause
shopify_app/graphql/admin_graphql.py:398 (sync):
time.sleep(int(retry_after))
and shopify_app/graphql/admin_graphql.py:454 (async):
await asyncio.sleep(int(retry_after))
Reproduction
>>> int("2.0")
Traceback (most recent call last):
...
ValueError: invalid literal for int() with base 10: '2.0'
Currently masked
This is not reachable today, because the header is never actually read: response_headers.get("Retry-After", "1") always returns its "1" default, for the reason described in #17.
That coupling is the reason this is worth filing on its own — repairing the header lookup alone turns a silent bug into an uncaught exception. The two are best addressed together.
Suggested fix
Parse defensively and fall back rather than raising:
try:
delay = float(retry_after)
except (TypeError, ValueError):
delay = 1.0
time.sleep(delay)
float() accepts the integer form as well, so it covers both spellings. If HTTP-date support is wanted, email.utils.parsedate_to_datetime handles that form.
- Ngôn ngữ chính
- Python
- Star
- 17
- Fork
- 1
- Merge trung bình
- 4 phút
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
- Không có Dockerfile hay 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 Shopify/shopify-app-python
-
devtools-gardener
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Tất cả issue của Shopify/shopify-app-python
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 91/100
TencentCloud/Octop#1577 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug frontend
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
PedestrianDynamics/pyFDS-Evac#552 ·
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 84/100
resend/resend-skills#144 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
update UV in dockerfileĐang mởgood first issue
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100