-
Notifications
You must be signed in to change notification settings - Fork 432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deleting object.metadata[key] doesn't work anymore #753
Comments
Thanks for the report @adrienverge. I think I know what's going on here... deleting a metadata key is handled differently if you're using a flow that relies on mutating an object and calling Looking at the options outlined in #596: Option 1: Mutate +
Notice that this uses a However you're right that
vs.
I don't think Option 2:
This still works, and is different than your code which actually mutates the local Stripe object and encounters that mentioned
This error message is very confusing... As an example, this works:
If you try using c = Stripe::Customer.create({
metadata: {'a': '1', 'b': '2'},
})
Stripe::Customer.update(c.id, {metadata: {'b': nil}})
c2 = Stripe::Customer.retrieve(c.id)
puts c2.metadata
# {
# "a": "1",
# "b": "2"
# } vs. c = Stripe::Customer.create({
metadata: {'a': '1', 'b': '2'},
})
Stripe::Customer.update(c.id, {metadata: {'b': ''}})
c2 = Stripe::Customer.retrieve(c.id)
puts c2.metadata
# {
# "a": "1"
# } To summarize, there's a few concepts being mixed in here:
The error message is very confusing here and we could likely clarify. |
I've clarified the deletion message. Going to close this as there is no regression ( |
Thanks for this detailed answer, which is really helpful to understand the problem 👍 👍 OK for For However, in my opinion the way stripe-python handles metadata is not consistent and confusion-prone (i.e. I still see a "bug"):
|
This is only happening because you're directly mutating the dict on customer. If you clone In general, treating the received Stripe objects as immutable is the way to go if you plan on using |
OK, makes sense. It's still confusing to be allowed to mutate the dict to |
arrived here from attempting to do a |
Python 3.10
stripe-python versions tested: 2.1.0, 2.20.0, 2.33.0, 2.63.0 (latest)
Stripe API 2020-08-27 (latest)
Hello,
Deleting customer metadata using
= None
ordel metadata[key]
does not work anymore. It used to work, as this other issue suggests.Strangely, all stripe-python versions tested (from 2.1.0 to 2.63.0) have the bug. This could show a change on the Stripe API, but this doesn't seem to be the case because using
curl
instead of the Python lib works (see examples below).How to reproduce:
However, using a raw HTTP request successfully removes
b
frommetadata
:The text was updated successfully, but these errors were encountered: