Skip to content

Conversation

@xavdid-stripe
Copy link
Member

Why?

Fixes a bug where the stripe_context property wasn't correctly persisted when making requests in an auto_paging_iter call. As a result, the first API call of a list would work, but subsequent pages wouldn't include stripe_context and could fail / use the wrong context. This was only an issue with stripe_context; stripe_account was unaffected.

import stripe

api_key = 'sk_org_test_123'

context = "ctx_123"
all_customers = stripe.Customer.list(stripe_context=context, limit=3, api_key=api_key)

# lists 3 customers successfully, then
# error_message='Please include the Stripe-Context header with your target account \
# when using an Organization API key.'
for customer in all_customers.auto_paging_iter():
    print(customer.id)

What?

  • (the actual fix) include "stripe-context" in the list of persisted keys
  • (refactor) rename _replace_options to _new_requestor_with_options to better describe the method
  • centralize keys that we persist to preempt another bug

See Also

@xavdid-stripe xavdid-stripe requested a review from a team as a code owner October 31, 2025 19:19
@xavdid-stripe xavdid-stripe merged commit d8dd636 into master Oct 31, 2025
19 checks passed
@xavdid-stripe xavdid-stripe deleted the RUN_DEVSDK-2021 branch October 31, 2025 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants