Stripe · sdk · fg-0149

metadata.get() raises AttributeError after upgrading stripe-python to v15

If you see AttributeError when calling .get(), .keys() or .values() on a Stripe object, the cause and the fix for Stripe are below, last verified 2026-10-15.

Verified Oct 2026trust 50/100
Symptom
AttributeError when calling .get(), .keys() or .values() on a Stripe objectdict(stripe_object) returns an empty dictUnit tests that build events as plain dicts pass while production webhooks return 500
Cause
Since v15 StripeObject no longer inherits from dict. Attribute access, bracket access and in still work, but dict methods are gone.
Fix
Use getattr with a default, or call to_dict() first. Build test events with StripeObject.construct_from so tests match production.
Apply
plan = getattr(session.metadata, "plan", None) # or plan = session.metadata.to_dict().get("plan")
Affected
stripe-python 15.0.0 (2026-03-25) and later
Sources

Last verified 2026-10-15 · Confirmed by 0 builders

Related traps

Have your agent know this before it fails

$ /plugin marketplace add getfootgun/footgun
$ /plugin install footgun@footgun