Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Async fetch_related_object_async / fetch_event_async send "usage" as an API parameter

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

メンテナーはふだん 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

環境構築

はじめの一歩

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

stripe/stripe-python のほかの issue

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

似ている issue

Python の issue をもっと見る

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

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