Jump to solution
Verify

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%.

Jump to Verify Open PR/Commit
@@ -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'):
repro.py
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
verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
fix.md
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).
Production impact:
  • 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

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…”
@ob-stripe · 2018-01-12 · source
“@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…”
@remi-stripe · 2018-01-11 · source
“Pushed a fix with @ob-stripe's patch in 1.77.1. Thanks @ob-stripe / @remi-stripe!”
@brandur-stripe · 2018-01-12 · source

Failure Signature (Search String)

  • AssertionError

Error Message

Stack trace
error.txt
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

repro.py
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

When NOT to use: This fix is not applicable if the behavior of unsaved attributes needs to remain unchanged.

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:

When NOT to use: This fix is not applicable if the behavior of unsaved attributes needs to remain unchanged.

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.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

When NOT to Use This Fix

  • This fix is not applicable if the behavior of unsaved attributes needs to remain unchanged.

Verify Fix

verify
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

VersionStatus
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.