chargebee / chargebee-python

Python library for the Chargebee API.
https://apidocs.chargebee.com/docs/api?lang=python
MIT License
40 stars 31 forks source link

[urgent] Bug in the newest SDK version #63

Open Ludotrico opened 1 month ago

Ludotrico commented 1 month ago

Description of the Bug

This is causing our webhooks to fail, very urgent bug in your SDK. Here is the error:

!!!! ERROR EXCEPTION handlePOST:4717: Traceback (most recent call last): File "/srv/cupidbot/helpers/helper.py", line 4715, in handlePOST return handle(payload) File "/srv/cupidbot/helpers/helper.py", line 4694, in handle response = function(payload) File "/srv/cupidbot/webhooks/chargebee.py", line 30, in chargebeeWebhookHandler ChargebeeWebhookHandler.handlePaymentSucceeded(payload) File "/srv/cupidbot/webhooks/chargebee.py", line 84, in handlePaymentSucceeded metadata = ChargebeeWebhookHandler.getMetadataFromHostedCheckoutPage(invoice['id'], minTimestamp) File "/srv/cupidbot/webhooks/chargebee.py", line 250, in getMetadataFromHostedCheckoutPage hostedPages = [r.hosted_page for r in results if r.hosted_page and r.hosted_page.content and r.hosted_page.content.invoice] File "/srv/cupidbot/webhooks/chargebee.py", line 250, in hostedPages = [r.hosted_page for r in results if r.hosted_page and r.hosted_page.content and r.hosted_page.content.invoice] File "/layers/google.python.pip/pip/lib/python3.9/site-packages/chargebee/result.py", line 148, in hosted_page hosted_page = self._get('hosted_page', HostedPage) File "/layers/google.python.pip/pip/lib/python3.9/site-packages/chargebee/result.py", line 489, in _get self._response_obj[type] = cls.construct(self._response[type], sub_types, dependant_types) File "/layers/google.python.pip/pip/lib/python3.9/site-packages/chargebee/model.py", line 49, in construct obj = cls(values, sub_types, dependant_types) File "/layers/google.python.pip/pip/lib/python3.9/site-packages/chargebee/model.py", line 18, in init__ setattr(self, field, None) AttributeError: can't set attribute

Any timeline on when this will be fixed? This code was working fine in the last SDK version.

To clarify, version 2.37.1 is working fine, version 2.39.0 is broken.

Steps to reproduce

Try to access elements in certain objects like HostedPage

Expected Behavior

No errors

Code Snippets (if applicable)

hostedPages = [r.hosted_page for r in results if r.hosted_page and r.hosted_page.content and r.hosted_page.content.invoice]

Operating System

macOS

Language version

Python 3.9.18

Library version

2.39.9

Additional context

No response

cb-alish commented 1 month ago

Hi @Ludotrico, seems like you are using v2.39.0. We have fixed this in our latest patch release, v2.39.1. Please install this version and let us know if you are still facing this issue.

pudo commented 1 month ago

@cb-alish We're still seeing a similar error in 2.39.1, preventing our users from checking out the product:

AttributeError: property 'content' of 'HostedPage' object has no setter

at .__init__ ( /venv/lib/python3.12/site-packages/chargebee/model.py:18 )
at .construct ( /venv/lib/python3.12/site-packages/chargebee/model.py:49 )
at ._get ( /venv/lib/python3.12/site-packages/chargebee/result.py:489 )
at .hosted_page ( /venv/lib/python3.12/site-packages/chargebee/result.py:148 )
at .chargebee_checkout ( /app/serviceapi/billing/router.py:60 )
cb-alish commented 1 month ago

Hi @pudo , can you please confirm if you are on v2.39.0 or v2.39.1 because it is working for us in v2.39.1? If you're on v2.39.1, can you please share a code snippet that results in the above error?