Jump to solution
Verify

The Fix

Fixes an issue where StripeObjects in lists would not be converted to dictionaries in the to_dict_recursive() method.

Based on closed stripe/stripe-python issue #695 · 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
@@ -278,11 +278,20 @@ def to_dict(self): def to_dict_recursive(self): - d = dict(self) - for k, v in six.iteritems(d): - if isinstance(v, StripeObject):
repro.py
import stripe stripe.api_key = 'sk_test_...' balance = stripe.Balance.retrieve() balance_dict = balance.to_dict_recursive() print(balance_dict)
verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
fix.md
Option A — Apply the official fix\nFixes an issue where StripeObjects in lists would not be converted to dictionaries in the to_dict_recursive() method.\nWhen NOT to use: Do not use this fix if you require the original StripeObject structure.\n\n

Why This Fix Works in Production

  • Trigger: Issue: If you use the method `to_dict_recursive()` on a `StripeObject` that hat lists of `StripeObject`s as values, the content of the lists will not be…
  • Mechanism: The to_dict_recursive() method did not convert StripeObjects in lists to dictionaries
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

  • Shows up under Python 3.7.2 in real deployments (not just unit tests).
  • The to_dict_recursive() method did not convert StripeObjects in lists to dictionaries
  • Production symptom (often without a traceback): Issue: If you use the method `to_dict_recursive()` on a `StripeObject` that hat lists of `StripeObject`s as values, the content of the lists will not be recursively changed to a dictionary.

Proof / Evidence

Discussion

High-signal excerpts from the issue thread (symptoms, repros, edge-cases).

“Flagging the code has been merged but we're experiencing some delays with the released of the new version. I'll update this thread once it's live!”
@remi-stripe · 2020-12-02 · confirmation · source
“Okay the version 2.55.1 should now be out!”
@remi-stripe · 2020-12-02 · source

Failure Signature (Search String)

  • Issue: If you use the method `to_dict_recursive()` on a `StripeObject` that hat lists of `StripeObject`s as values, the content of the lists will not be recursively changed to a
  • I'll open a PR with a simple fix. I'm not sure what a good style guide on list comprehensions is so you might want to change it, but the idea of the PR is fairly straightforward.
Copy-friendly signature
signature.txt
Failure Signature ----------------- Issue: If you use the method `to_dict_recursive()` on a `StripeObject` that hat lists of `StripeObject`s as values, the content of the lists will not be recursively changed to a dictionary. I'll open a PR with a simple fix. I'm not sure what a good style guide on list comprehensions is so you might want to change it, but the idea of the PR is fairly straightforward.

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- Issue: If you use the method `to_dict_recursive()` on a `StripeObject` that hat lists of `StripeObject`s as values, the content of the lists will not be recursively changed to a dictionary. I'll open a PR with a simple fix. I'm not sure what a good style guide on list comprehensions is so you might want to change it, but the idea of the PR is fairly straightforward.

Minimal Reproduction

repro.py
import stripe stripe.api_key = 'sk_test_...' balance = stripe.Balance.retrieve() balance_dict = balance.to_dict_recursive() print(balance_dict)

Environment

  • Python: 3.7.2

What Broke

Using to_dict_recursive() resulted in incomplete dictionary representations of StripeObjects.

Why It Broke

The to_dict_recursive() method did not convert StripeObjects in lists to dictionaries

Fix Options (Details)

Option A — Apply the official fix

Fixes an issue where StripeObjects in lists would not be converted to dictionaries in the to_dict_recursive() method.

When NOT to use: Do not use this fix if you require the original StripeObject structure.

Fix reference: https://github.com/stripe/stripe-python/pull/698

Last verified: 2026-02-11. Validate in your environment.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

When NOT to Use This Fix

  • Do not use this fix if you require the original StripeObject structure.

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.

Related Issues

No related fixes found.

Sources

We don’t republish the full GitHub discussion text. Use the links above for context.