Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
Labels

Description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /