Conversation
* add "prepare" to justfile * add Stripe-Request-Trigger header
There was a problem hiding this comment.
Pull request overview
This PR appears to sync changes into the beta branch by updating event-fetch request behavior and a few release/tooling metadata bits in the Stripe Python SDK.
Changes:
- Add a
Stripe-Request-Trigger: event=<event_id>header to requests made when fetching events and their related objects (sync + async) across v1/v2 event notification types. - Update the v2 event integration test to assert the new request header is sent.
- Extend AI agent environment-variable detection for User-Agent reporting, add a
just prepareconvenience target, and update the changelog.
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_v2_event.py | Asserts Stripe-Request-Trigger is included on event + related-object fetch requests. |
| stripe/v2/core/_event.py | Adds Stripe-Request-Trigger header to EventNotification.fetch_event* and UnknownEventNotification.fetch_related_object*. |
| stripe/events/_v2_core_event_destination_ping_event.py | Adds Stripe-Request-Trigger header to related-object fetches. |
| stripe/events/_v2_core_account_updated_event.py | Adds Stripe-Request-Trigger header to related-object fetches. |
| stripe/events/_v2_core_account_person_updated_event.py | Adds Stripe-Request-Trigger header to related-object fetches. |
| stripe/events/_v2_core_account_person_deleted_event.py | Adds Stripe-Request-Trigger header to related-object fetches. |
| stripe/events/_v2_core_account_person_created_event.py | Adds Stripe-Request-Trigger header to related-object fetches. |
| stripe/events/_v2_core_account_including_requirements_updated_event.py | Adds Stripe-Request-Trigger header to related-object fetches. |
| stripe/events/_v2_core_account_including_identity_updated_event.py | Adds Stripe-Request-Trigger header to related-object fetches. |
| stripe/events/_v2_core_account_including_future_requirements_updated_event.py | Adds Stripe-Request-Trigger header to related-object fetches. |
| stripe/events/_v2_core_account_including_defaults_updated_event.py | Adds Stripe-Request-Trigger header to related-object fetches. |
| stripe/events/_v2_core_account_including_configuration_recipient_updated_event.py | Adds Stripe-Request-Trigger header to related-object fetches. |
| stripe/events/_v2_core_account_including_configuration_recipient_capability_status_updated_event.py | Adds Stripe-Request-Trigger header to related-object fetches. |
| stripe/events/_v2_core_account_including_configuration_merchant_updated_event.py | Adds Stripe-Request-Trigger header to related-object fetches. |
| stripe/events/_v2_core_account_including_configuration_merchant_capability_status_updated_event.py | Adds Stripe-Request-Trigger header to related-object fetches. |
| stripe/events/_v2_core_account_including_configuration_customer_updated_event.py | Adds Stripe-Request-Trigger header to related-object fetches. |
| stripe/events/_v2_core_account_including_configuration_customer_capability_status_updated_event.py | Adds Stripe-Request-Trigger header to related-object fetches. |
| stripe/events/_v2_core_account_created_event.py | Adds Stripe-Request-Trigger header to related-object fetches. |
| stripe/events/_v2_core_account_closed_event.py | Adds Stripe-Request-Trigger header to related-object fetches. |
| stripe/events/_v1_billing_meter_error_report_triggered_event.py | Adds Stripe-Request-Trigger header to related-object fetches for this v1 event type. |
| stripe/_api_requestor.py | Expands AI agent env-var detection list for User-Agent reporting. |
| justfile | Adds prepare target to run format/lint/typecheck/tests locally. |
| CHANGELOG.md | Documents the header addition and AI agent User-Agent update in 14.4.1. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| self.related_object.url, | ||
| stripe_context=self.context, | ||
| headers={"Stripe-Request-Trigger": f"event={self.id}"}, | ||
| usage=["fetch_related_object", "unknown_event"], |
There was a problem hiding this comment.
Same issue as in fetch_event_async(): usage= is passed into StripeClient.raw_request_async, which currently forwards unknown kwargs (including usage) as request params because it doesn’t pop them. This makes async fetch_related_object_async() send an unintended usage parameter to the API.
| usage=["fetch_related_object", "unknown_event"], |
| f"/v2/core/events/{self.id}", | ||
| stripe_context=self.context, | ||
| headers={"Stripe-Request-Trigger": f"event={self.id}"}, | ||
| usage=["pushed_event_pull", "pushed_event_pull_async"], |
There was a problem hiding this comment.
fetch_event_async() (and other async helpers calling StripeClient.raw_request_async) pass a usage= kwarg, but StripeClient.raw_request_async does not pop/consume usage the way raw_request does. As a result, usage will be forwarded as a request param/query field, which can change request semantics and leak internal instrumentation. Fix by updating StripeClient.raw_request_async to usage = params.pop("usage", ["raw_request"]) and pass that through to request_raw_async, or stop passing usage from these async event methods until the client is fixed.
| usage=["pushed_event_pull", "pushed_event_pull_async"], |
Why?
What?
See Also