For webhooks, `webhook.request` is both a method and a data attribute
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start by locating the StripeObject.request method and the webhook event construction path. Reproduce the difference between event.request and event["request"], then inspect related tests or compatibility expectations. Done means the webhook request data is accessible consistently without losing the method's intended behavior.
Written by the indexing model from the issue text.
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
- Construct a webhook event.
- Access
event.request. - Access
event["request"]. - 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
- Dominant language
- Python
- Stars
- 2k
- Forks
- 539
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 26
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from stripe/stripe-python
-
feature-request future
Difficulty 4/5 3-5 days Newbie friendliness 35/100
stripe/stripe-python#1886 · 1 comment ·
-
feature-request
Difficulty 2/5 1-3 hours Newbie friendliness 54/100
stripe/stripe-python#1841 · 1 comment ·
-
feature-request future
Difficulty 3/5 1-2 days Newbie friendliness 52/100
stripe/stripe-python#1812 · 1 comment ·
-
feature-request future
Difficulty 3/5 1-2 days Newbie friendliness 74/100
stripe/stripe-python#1796 · 3 comments ·
-
feature-request future
Difficulty 4/5 3-5 days Newbie friendliness 38/100
stripe/stripe-python#1465 · 4 comments · 2 reactions ·
All issues in stripe/stripe-python
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
bancolombia/sentinel#23 ·
-
test md OpenCI
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
bug client
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100