For webhooks, `webhook.request` is both a method and a data attribute
Maintainers usually reply within 2 days
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
- 2.1k
- Forks
- 538
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 28
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing 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
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
stripe/stripe-python#1936 · 2 comments ·
Maintainers usually reply within 2 days
-
feature-request future
Difficulty 4/5 3-5 days Newbie friendliness 35/100
stripe/stripe-python#1886 · 1 comment ·
Maintainers usually reply within 2 days
-
feature-request
Difficulty 2/5 1-3 hours Newbie friendliness 54/100
stripe/stripe-python#1841 · 1 comment ·
Maintainers usually reply within 2 days
-
feature-request future
Difficulty 3/5 1-2 days Newbie friendliness 52/100
stripe/stripe-python#1812 · 1 comment ·
Maintainers usually reply within 2 days
-
Add async context manager support for AIOHTTPClient and HTTPXClientMay be free again A pull request for this issue was closed without being merged. Openfeature-request future
Difficulty 3/5 1-2 days Newbie friendliness 74/100
stripe/stripe-python#1796 · 3 comments ·
Maintainers usually reply within 2 days
All issues in stripe/stripe-python
Similar issues
-
docs pydanty:is-working
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
pydantic/pydantic-ai#9800 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
[Bug]: With --api-server-count > 1, gauges such as vllm:num_requests_running have no samples until the first requestPossibly taken @roy6n23 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
vllm-project/vllm#59988 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
pymc-devs/pymc-examples#897 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 91/100