Infinite recursion when webhook gets called
See original GitHub issueDescribe the bug When the dj-stripe webhook gets called, it enters an infinite recursion which eventually raises an exception with the message “maximum recursion depth exceeded while calling a Python object”
To Reproduce
- Install dj-stripe
- Put Stripe into “view test data” mode so we can work with test data.
settings.STRIPE_LIVE_MODE
should beFalse
- Point your stripe account to use at your server’s
/stripe/webhook/
endpoint as a webhook - Using test mode, purchase a subscription using your application, or re-send a failed webhook attempt of type
invoice.payment_succeeded
(not sure if this happens for other event types) - Watch the dj-stripe webhook get called (
ProcessWebhookView.post
), but this call never completes, as the code enters an infinite recursion
I can set a breakpoint in djstripe.models.core.Event.invoke_webhook_handlers
and when I try to step over the line of code webhooks.call_handlers(event=self)
, the code goes into an infinite recursion which eventually times out. I am including a portion of this stack trace (the same lines repeat over and over since it’s an infinite recursion). I am also attaching the event JSON.
Expected behavior Successful processing of webhook.
Environment
- dj-stripe version: master
- Your Stripe account’s default API version: 2020-03-02
- Database: Postgres
- Python version: 3.6.2
- Django version: 3.0.2
Can you reproduce the issue with the latest version of master?
Yes
Additional context Here is a snippet of the repeating stack trace, and the event data is attached to this ticket as a file.
File "/Users/ghassett/.virtualenvs/wwapiserver/lib/python3.6/site-packages/djstripe/models/base.py", line 340, in _stripe_object_field_to_foreign_key
stripe_account=stripe_account,
File "/Users/ghassett/.virtualenvs/wwapiserver/lib/python3.6/site-packages/djstripe/models/base.py", line 532, in _get_or_create_from_stripe_object
stripe_account=stripe_account,
File "/Users/ghassett/.virtualenvs/wwapiserver/lib/python3.6/site-packages/djstripe/models/base.py", line 430, in _create_from_stripe_object
stripe_account=stripe_account,
File "/Users/ghassett/.virtualenvs/wwapiserver/lib/python3.6/site-packages/djstripe/models/base.py", line 239, in _stripe_object_to_record
stripe_account=stripe_account,
File "/Users/ghassett/.virtualenvs/wwapiserver/lib/python3.6/site-packages/djstripe/models/base.py", line 340, in _stripe_object_field_to_foreign_key
stripe_account=stripe_account,
File "/Users/ghassett/.virtualenvs/wwapiserver/lib/python3.6/site-packages/djstripe/models/base.py", line 532, in _get_or_create_from_stripe_object
stripe_account=stripe_account,
File "/Users/ghassett/.virtualenvs/wwapiserver/lib/python3.6/site-packages/djstripe/models/base.py", line 430, in _create_from_stripe_object
stripe_account=stripe_account,
File "/Users/ghassett/.virtualenvs/wwapiserver/lib/python3.6/site-packages/djstripe/models/base.py", line 239, in _stripe_object_to_record
stripe_account=stripe_account,
File "/Users/ghassett/.virtualenvs/wwapiserver/lib/python3.6/site-packages/djstripe/models/base.py", line 340, in _stripe_object_field_to_foreign_key
stripe_account=stripe_account,
File "/Users/ghassett/.virtualenvs/wwapiserver/lib/python3.6/site-packages/djstripe/models/base.py", line 532, in _get_or_create_from_stripe_object
stripe_account=stripe_account,
File "/Users/ghassett/.virtualenvs/wwapiserver/lib/python3.6/site-packages/djstripe/models/base.py", line 430, in _create_from_stripe_object
stripe_account=stripe_account,
File "/Users/ghassett/.virtualenvs/wwapiserver/lib/python3.6/site-packages/djstripe/models/base.py", line 239, in _stripe_object_to_record
stripe_account=stripe_account,
File "/Users/ghassett/.virtualenvs/wwapiserver/lib/python3.6/site-packages/djstripe/models/base.py", line 340, in _stripe_object_field_to_foreign_key
stripe_account=stripe_account,
File "/Users/ghassett/.virtualenvs/wwapiserver/lib/python3.6/site-packages/djstripe/models/base.py", line 532, in _get_or_create_from_stripe_object
stripe_account=stripe_account,
File "/Users/ghassett/.virtualenvs/wwapiserver/lib/python3.6/site-packages/djstripe/models/base.py", line 430, in _create_from_stripe_object
stripe_account=stripe_account,
File "/Users/ghassett/.virtualenvs/wwapiserver/lib/python3.6/site-packages/djstripe/models/base.py", line 239, in _stripe_object_to_record
stripe_account=stripe_account,
File "/Users/ghassett/.virtualenvs/wwapiserver/lib/python3.6/site-packages/djstripe/models/base.py", line 340, in _stripe_object_field_to_foreign_key
stripe_account=stripe_account,
File "/Users/ghassett/.virtualenvs/wwapiserver/lib/python3.6/site-packages/djstripe/models/base.py", line 532, in _get_or_create_from_stripe_object
stripe_account=stripe_account,
File "/Users/ghassett/.virtualenvs/wwapiserver/lib/python3.6/site-packages/djstripe/models/base.py", line 430, in _create_from_stripe_object
stripe_account=stripe_account,
File "/Users/ghassett/.virtualenvs/wwapiserver/lib/python3.6/site-packages/djstripe/models/base.py", line 239, in _stripe_object_to_record
stripe_account=stripe_account,
File "/Users/ghassett/.virtualenvs/wwapiserver/lib/python3.6/site-packages/djstripe/models/base.py", line 340, in _stripe_object_field_to_foreign_key
stripe_account=stripe_account,
File "/Users/ghassett/.virtualenvs/wwapiserver/lib/python3.6/site-packages/djstripe/models/base.py", line 532, in _get_or_create_from_stripe_object
stripe_account=stripe_account,
File "/Users/ghassett/.virtualenvs/wwapiserver/lib/python3.6/site-packages/djstripe/models/base.py", line 430, in _create_from_stripe_object
stripe_account=stripe_account,
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:19 (7 by maintainers)
Top GitHub Comments
Hi @lmeyerov
The fix is in
master
but not in thelatest
release yet. It should land in thenext release.
I’ll be able to work on this Sunday and next week. Sorry for the delays everyone, this has been a busy new years period.