The Fix
pip install stripe==10.3.0
Based on closed stripe/stripe-python issue #388 · PR/commit linked
Production note: Most teams hit this during upgrades or environment changes. Roll out with a canary and smoke critical endpoints (health, OpenAPI/docs) before 100%.
@@ -98,12 +98,11 @@ def __setitem__(self, k, v):
k, str(self), k))
- if not hasattr(self, k) or v != getattr(self, k):
- # Allows for unpickling in Python 3.x
- if not hasattr(self, '_unsaved_values'):
subscription = stripe.Subscription.retrieve({SUBSCRIPTION_ID})
assert subscription.plan == 'plan1'
assert subscription.quantity == 2
subscription.plan = 'plan2'
subscription.quantity = 2
subscription.save()
subscription = stripe.Subscription.retrieve({SUBSCRIPTION_ID})
assert subscription.quantity == 2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AssertionError
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Upgrade to fixed release\npip install stripe==10.3.0\nWhen NOT to use: This fix is not applicable if the behavior of unsaved attributes needs to remain unchanged.\n\nOption C — Workaround\nis to set a different value, then immediately set it back. E.g. in your case:\nWhen NOT to use: This fix is not applicable if the behavior of unsaved attributes needs to remain unchanged.\n\n
Why This Fix Works in Production
- Trigger: AssertionError
- Mechanism: The library only registers an attribute as unsaved when its value changes
- Why the fix works: The fix registers unsaved attributes on assignment regardless of whether the new value is different, aligning the behavior with other libraries. (first fixed release: 10.3.0).
- If left unfixed, the same config can fail only in production (env differences), causing startup failures or partial feature outages.
Why This Breaks in Prod
- The library only registers an attribute as unsaved when its value changes
- Surfaces as: subscription = stripe.Subscription.retrieve({SUBSCRIPTION_ID})
Proof / Evidence
- GitHub issue: #388
- Fix PR: https://github.com/stripe/stripe-python/pull/389
- First fixed release: 10.3.0
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.70
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.53
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“This issue is caused by the fact that the Python library will only register an attribute as an unsaved value when it is updated with…”
“@alanhamlett Thanks a lot for the report! I think that the issue here is that quantity does not change so it's not sent to the…”
“Pushed a fix with @ob-stripe's patch in 1.77.1. Thanks @ob-stripe / @remi-stripe!”
Failure Signature (Search String)
- AssertionError
Error Message
Stack trace
Error Message
-------------
subscription = stripe.Subscription.retrieve({SUBSCRIPTION_ID})
assert subscription.plan == 'plan1'
assert subscription.quantity == 2
subscription.plan = 'plan2'
subscription.quantity = 2
subscription.save()
subscription = stripe.Subscription.retrieve({SUBSCRIPTION_ID})
assert subscription.quantity == 2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AssertionError
Minimal Reproduction
subscription = stripe.Subscription.retrieve({SUBSCRIPTION_ID})
assert subscription.plan == 'plan1'
assert subscription.quantity == 2
subscription.plan = 'plan2'
subscription.quantity = 2
subscription.save()
subscription = stripe.Subscription.retrieve({SUBSCRIPTION_ID})
assert subscription.quantity == 2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AssertionError
What Broke
Updating subscription plan results in incorrect quantity being sent to the API.
Why It Broke
The library only registers an attribute as unsaved when its value changes
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install stripe==10.3.0
Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.
Option C — Workaround Temporary workaround
is to set a different value, then immediately set it back. E.g. in your case:
Use only if you cannot change versions today. Treat this as a stopgap and remove once upgraded.
Fix reference: https://github.com/stripe/stripe-python/pull/389
First fixed release: 10.3.0
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix is not applicable if the behavior of unsaved attributes needs to remain unchanged.
Verify Fix
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Did This Fix Work in Your Case?
Quick signal helps us prioritize which fixes to verify and improve.
Prevention
- Capture the exact failing error string in logs and tests so you can reproduce via a minimal script.
- Pin production dependencies and upgrade only with a reproducible test that hits the failing path.
Version Compatibility Table
| Version | Status |
|---|---|
| 10.3.0 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.