Repository navigation
Omit API keys from StripeObject pickles and add explicit key rebinding 🪿✨ #1959
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
Merged
zacchua-stripe
merged 18 commits into
sdk-release/next-major
from
fix/pickle-credentials
Nov 10, 2026
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
78952be
[🪿] Omit API keys from StripeObject pickles
zacchua-stripe c11d090
[🪿] try to deslop
zacchua-stripe 096a7e3
[🪿] Align pickle credential migration with v17
zacchua-stripe e34a040
[🪿] try to deslop
zacchua-stripe d7c529d
[🪿] Update PyPI publishing action to v1.14.3
zacchua-stripe 427f81f
[🪿] Revert unrelated PyPI publishing action upgrade
zacchua-stripe 9391eec
[🪿] Update pickle credential changefile wording and filename
zacchua-stripe d0bef0d
[🪿] Simplify v17 pickle migration guidance
zacchua-stripe af9487d
[🪿] Replace set_api_key with per-call API keys on instance methods
zacchua-stripe b57fe37
[🪿] Trim pickle credential changefile wording
zacchua-stripe 53638b6
Merge branch 'master' into fix/pickle-credentials
zacchua-stripe b3a10a9
Require explicit API key reattachment after unpickling
zacchua-stripe 1c9e204
Keep serialized placeholders in requestors and guard requests centrally
zacchua-stripe ee7b14b
Clarify API key reattachment wording in changefile
zacchua-stripe 276b7ab
Clarify API key reattachment migration guidance
zacchua-stripe 131602e
Address serialization documentation review feedback
zacchua-stripe f6c8de4
Make migration guide before/after examples equivalent
zacchua-stripe fc1d7b3
Merge branch 'sdk-release/next-major' into fix/pickle-credentials
zacchua-stripe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
.hark/changes/2026-10-30_zacchua_omit-pickled-api-keys.change.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| title: Omit API keys from pickled StripeObjects | ||
| semver_level: major | ||
| --- | ||
| StripeObject pickles no longer preserve API keys. Before making requests through an unpickled object, call `reattach_api_key(api_key)`. This also reattaches API keys to nested objects. | ||
|
|
||
| See the [v17 migration guide](https://github.com/stripe/stripe-python/blob/master/.hark/migration-guides/v17.md#api-keys-are-no-longer-preserved-in-pickled-stripeobjects) for details. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| # Migration guide for v17 | ||
| ## API keys are no longer preserved in pickled StripeObjects | ||
| This affects integrations that persist StripeObjects in caches or queues and then make requests through the restored objects. | ||
|
|
||
| Pickling now replaces API keys with a placeholder, including on nested objects. Unpickled objects retain their data, connected-account routing, and API version but have no API key. Before making requests through an unpickled object, call `reattach_api_key()` with a key from secure configuration: | ||
|
|
||
| ```python | ||
| # Before | ||
| customer = pickle.loads(trusted_cached_bytes) | ||
| customer.refresh() | ||
|
|
||
| # After | ||
| customer = pickle.loads(trusted_cached_bytes) | ||
| customer.reattach_api_key(api_key) | ||
| customer.refresh() | ||
| ``` | ||
|
|
||
| Reattach the API key the same way on unpickled lists and events before making requests through them: | ||
|
|
||
| ```python | ||
| customers = pickle.loads(trusted_cached_list_bytes) | ||
| customers.reattach_api_key(api_key) | ||
| for customer in customers.auto_paging_iter(): | ||
| ... | ||
|
|
||
| event = pickle.loads(trusted_cached_event_bytes) | ||
| event.reattach_api_key(api_key) | ||
| related_object = event.fetch_related_object() | ||
| ``` | ||
|
|
||
| `reattach_api_key()` also attaches API keys to nested unpickled objects. Each retains its saved API version and connected account. Nested objects that already have an API key keep it. Reattachment does not change `stripe.api_key`, and pickling the object again omits the reattached key. | ||
|
|
||
| Requests before reattachment raise `AuthenticationError` with instructions to call `reattach_api_key()`, even if you set a global or per-call API key. | ||
|
|
||
| Calling `reattach_api_key()` more than once, or on an object whose API key wasn't replaced with the serialization placeholder, raises `ValueError`. Passing an empty key or the serialization placeholder also raises `ValueError`. | ||
|
|
||
| This behavior applies to pickles created with v17. Pickles created with earlier versions can still contain API keys. Remove or replace those stored pickles according to your application's storage policy. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.