int(retry_after) raises ValueError on a non-integer Retry-After value
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 78/100
調査の方向性
shopify_app/graphql/admin_graphql.py の、398 行目と 454 行目付近にある admin_graphql_request の同期および非同期の retry ハンドラーから始めます。Retry-After の取得方法を追跡し、そのうえで、小数値または無効な値が ValueError として外部に漏れなくなっていること、また両方のハンドラーが引き続き retry または GQLResult の動作を維持していることを確認します。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- Python
- スター
- 17
- フォーク
- 1
- 平均マージ
- 4分
- マージ済み PR(30日)
- 1
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Shopify/shopify-app-python のほかの issue
-
devtools-gardener
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
Shopify/shopify-app-python の issue をすべて見る
似ている issue
-
New Internshipオープンnew_internship
難易度 1/5 1時間未満 初心者へのやさしさ 70/100
-
[BUG] Reports tab: "Unban" button tooltip shows raw `{{ip}}` placeholder instead of the IP addressオープンbug javascript ui
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
bunkerity/bunkerweb#4001 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
PedestrianDynamics/pyFDS-Evac#476 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
google/differential-privacy#516 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
adobe-fonts/source-serif#153 ·