Async fetch_related_object_async / fetch_event_async send "usage" as an API parameter
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 90/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- python
調査の方向性
まず stripe/_stripe_client.py の raw_request と raw_request_async から始め、次に usage を渡す非同期イベントヘルパーを追跡します。提供された再現手順を stripe-mock に対して実行し、非同期の GET および POST リクエストが内部パラメーター usage を省略しつつ、呼び出し元から提供されたテレメトリーを保持することを確認します。また、両方の 针对的なクライアントテストを追加または更新します。
索引モデルが issue の本文から書いたものです。
説明
What happens
StripeClient.raw_request_async does not remove the internal usage keyword from params the way raw_request does. The SDK's own event notification helpers pass usage=[...] to it, so every async fetch adds usage[0]=... to the request.
For a related object with a v1 URL the API rejects the request as an unknown parameter. Against stripe-mock:
sync: Meter
async error: InvalidRequestError Request req_123: Request validation error: ... additional properties are not allowed
Request URLs observed with a stub HTTP client for the same notification:
sync get https://api.stripe.com/v1/accounts/acct_123
async get https://api.stripe.com/v1/accounts/acct_123?usage[0]=fetch_related_object
fetch_event_async() has the same problem (/v2/core/events/evt_...?usage[0]=pushed_event_pull&usage[1]=pushed_event_pull_async). The request telemetry also reports ["raw_request", "async"] instead of the usage the caller passed.
What should happen
The async path should behave like the sync path: usage is consumed as telemetry and never sent to the API.
Minimal repro
import asyncio, json, stripe
client = stripe.StripeClient("sk_test_123", base_addresses={"api": "http://localhost:12111"}) # stripe-mock
payload = json.dumps({
"id": "evt_1", "object": "v2.core.event",
"type": "v1.billing.meter.error_report_triggered",
"created": "2024-01-01T00:00:00Z", "livemode": False,
"related_object": {"id": "mtr_123", "type": "billing.meter", "url": "/v1/billing/meters/mtr_123"},
})
notif = client.parse_event_notification_without_verification(payload)
notif.fetch_related_object() # works
asyncio.run(notif.fetch_related_object_async()) # InvalidRequestError
Root cause
In stripe/_stripe_client.py, raw_request does usage = params.pop("usage", ["raw_request"]), but raw_request_async hardcodes usage=["raw_request"] and leaves usage inside params, which are then encoded into the query string (GET) or body (POST).
Tested on master at aff846c (16.0.0).
- 主要言語
- Python
- スター
- 2.1k
- フォーク
- 539
- 平均マージ
- 3日 5時間
- マージ済み PR(30日)
- 17
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
stripe/stripe-python のほかの issue
-
Boolean list elements are encoded as True/False instead of true/false対応中かも @inchang-ing が 1 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
stripe/stripe-python#1947 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
stripe/stripe-python#1936 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
feature-request future
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
stripe/stripe-python#1941 · コメント 6 件 ·
メンテナーはふだん 1 日以内に返信
-
feature-request future
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
stripe/stripe-python#1886 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
feature-request
難易度 2/5 1〜3時間 初心者へのやさしさ 54/100
stripe/stripe-python#1841 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
stripe/stripe-python の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
ansys/pyansys-common-mcp#213 ·
メンテナーはふだん 3 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
freedomofpress/dangerzone#1594 ·
メンテナーはふだん 3 日以内に返信
-
priority:P1 status:in-review type:bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
randomparity/kdive#3317 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
area:ci
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
mesonbuild/meson#16281 ·
メンテナーはふだん 1 日以内に返信