Skip to content
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

Setting a List Field to [] When Modifying a Resource Doesn't Actually Empty The List Field #802

Open
jake-kent opened this issue Apr 28, 2022 · 1 comment
Labels

Comments

@jake-kent
Copy link

jake-kent commented Apr 28, 2022

Describe the bug

When trying to clear out the list of previously set blocked_categories on a cardholder, calling

stripe.issuing.Cardholder.modify(
    "ich_...",
    spending_controls={'blocked_categories': []},
    stripe_account="acct_...",
)

returns successfully but doesn't clear out the blocked_categories on the cardholder and returns a cardholder instance with the previous blocked_categories list still set.

Instead, it is necessary to replace [] with "":

stripe.issuing.Cardholder.modify(
    "ich_...",
    spending_controls={'blocked_categories': ""},
    stripe_account="acct_...",
)

and that successfully clears the list of blocked_categories—however, there is no mention of the need to make this distinction when calling stripe.issuing.Cardholder.modify or any other method in the Stripe API docs or this library's docs and setting a list to empty by setting its value to "" is not valid Python syntax.

To Reproduce

  1. create a stripe connect account via:
stripe.Account.create(
    type="custom",
    country="US",
    email="testaccount@emailprovider.com",
    requested_capabilities=["transfers", "card_payments", "card_issuing"],
)
  1. complete any requested test KYB information to ensure the account is fully verified and approved
  2. create a cardholder via:
stripe.issuing.Cardholder.create(
    name="Jane Doe",
    email="testcardholder@emailprovider.com",
    status="active",
    type="individual",
    billing={
        "name": "Jane Doe",
        "address": {
            "line1": "117 West St",
            "line2": None,
            "city": "New York",
            "state": "NY",
            "country": "US",
            "postal_code": "10006",
        },
    },
    spending_controls={'blocked_categories': ['floor_covering_stores']},
    stripe_account="acct_...",  # id of the account created above
)
  1. attempt to update the cardholder via:
stripe.issuing.Cardholder.modify(
    "ich_...",  # id of the cardholder created above
    spending_controls={'blocked_categories': []},
    stripe_account="acct_...",  # id of the account created above
)

Expected behavior

Setting a list to [] should set that list to empty. It is not intuitive or valid Python syntax to set a list to empty by setting its value to "".

Code snippets

See code snippets in the "Describe the bug" and "To Reproduce" sections

OS

macOS

Language version

Python 3.10.2

Library version

stripe-python v2.67.0

API version

2019-10-17

Additional context

No response

@richardm-stripe
Copy link
Contributor

Somewhat related issue, some users have requested setting objects like Metadata to None should result in transmitting the empty string to unset: #753 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants