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

For webhooks, `webhook.request` is both a method and a data attribute

オープン
#825 コメント 4 件 リアクション 2 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python
領域
api, backend

調査の方向性

まず StripeObject.request メソッドと webhook イベントの構築経路を特定します。event.request と event["request"] の違いを再現し、その後、関連するテストや互換性に関する想定を確認します。Webhook リクエストデータに一貫してアクセスでき、メソッドが本来意図している動作を失わなければ完了です。

索引モデルが issue の本文から書いたものです。

説明

bug future
Describe the bug

Incoming webhook events have a request data attribute, but the event instance already has a request bound method, so we end up with a bit of a conflict. The data attribute can still be accessed with event["request"] but it feels weird to need to do that for just that one data attribute and then use dot syntax for everything else.

>>> event = stripe.Webhook.construct_event(...)

>>> event.request
<bound method StripeObject.request of <Event event id=<id_omitted> at 0x1035bb450> JSON: { ...

>>> event["request"]
<StripeObject id=<id_omitted> at 0x102e95810> JSON: {
  "id": "<id_omitted>",
  "idempotency_key": "<idempotency_key_omitted>"
}

event.request and event["request"] both returning different things is rather confusing, and it took me quite a while to figure out what was going on.

To Reproduce
  1. Construct a webhook event.
  2. Access event.request.
  3. Access event["request"].
  4. Notice that they are different.

I would probably consider this less of a "bug" and more of an oversight.

Expected behavior

The event.request method should probably be something like event._request so it doesn't conflict with the incoming data. That way I can call event.request and actually get the attribute from the body of the webhook as expected.

Code snippets

No response

OS

macOS

Language version

Python 3.9.10

Library version

stripe-python v2.76.0

API version

2020-08-27

Additional context

No response

主要言語
Python
スター
2.1k
フォーク
538
平均マージ
2日 16時間
マージ済み PR(30日)
28

環境構築

はじめの一歩

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

stripe/stripe-python のほかの issue

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

似ている issue

Python の issue をもっと見る

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

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