Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(data-warehouse): stop offering webhook sync for stripe BalanceTransaction (#112822)

posthog[bot]bf40c61d15eb
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/stripe/constants.py b/products/warehouse_sources/backend/temporal/data_imports/sources/stripe/constants.py
index 9a62ede541af..e466ab4423c4 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/stripe/constants.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/stripe/constants.py
@@ -77,7 +77,6 @@ PAYMENT_METHOD_HISTORY_MAPPING_KEY = "payment_method:history"
# (see `StripeSource.webhook_mapping_key`).
RESOURCE_TO_STRIPE_OBJECT_TYPE: dict[str, str] = {
ACCOUNT_RESOURCE_NAME: "account",
- BALANCE_TRANSACTION_RESOURCE_NAME: "balance_transaction",
CHARGE_RESOURCE_NAME: "charge",
CUSTOMER_RESOURCE_NAME: "customer",
DISPUTE_RESOURCE_NAME: "dispute",
@@ -118,7 +117,6 @@ RESOURCE_TO_STRIPE_OBJECT_TYPE: dict[str, str] = {
RESOURCE_TO_STRIPE_WEBHOOK_EVENT: dict[str, str] = {
ACCOUNT_RESOURCE_NAME: "account",
- BALANCE_TRANSACTION_RESOURCE_NAME: "transfer",
CHARGE_RESOURCE_NAME: "charge",
CUSTOMER_RESOURCE_NAME: "customer",
DISPUTE_RESOURCE_NAME: "dispute",
@@ -162,9 +160,6 @@ RESOURCE_TO_STRIPE_WEBHOOK_EVENT: dict[str, str] = {
INVOICE_PAYMENT_RESOURCE_NAME: "invoice_payment",
SETUP_INTENT_RESOURCE_NAME: "setup_intent",
PAYMENT_LINK_RESOURCE_NAME: "payment_link",
- # Duplicates the "transfer" prefix BalanceTransaction already carries. Harmless: this map's
- # values are collapsed to a set to build the subscription, and the two tables stay distinct
- # because routing keys off the object type (`balance_transaction` vs `transfer`), not the event.
TRANSFER_RESOURCE_NAME: "transfer",
APPLICATION_FEE_RESOURCE_NAME: "application_fee",
TOPUP_RESOURCE_NAME: "topup",
@@ -173,6 +168,8 @@ RESOURCE_TO_STRIPE_WEBHOOK_EVENT: dict[str, str] = {
# Deliberately absent, because Stripe emits no event carrying these objects. Verified against
# the `enabled_events` literal in the pinned SDK, which is the same list `_all_known_webhook_events`
# filters. They stay API-sweep-only:
+ # BalanceTransaction - no `balance_transaction.*` events exist; `transfer.*` events carry a
+ # `transfer` object, so a webhook-mode BalanceTransaction table would never receive a row
# SubscriptionItem - changes ride along on `customer.subscription.*` as nested `items`
# SetupAttempt - no `setup_attempt.*` events exist
# ShippingRate - no `shipping_rate.*` events exist
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/stripe/tests/test_stripe_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/stripe/tests/test_stripe_source.py
index d0d099f3a1fe..4f8ecb2e4dc2 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/stripe/tests/test_stripe_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/stripe/tests/test_stripe_source.py
@@ -35,6 +35,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.generated_
from products.warehouse_sources.backend.temporal.data_imports.sources.stripe import stripe as stripe_module
from products.warehouse_sources.backend.temporal.data_imports.sources.stripe.constants import (
APPLICATION_FEE_RESOURCE_NAME,
+ BALANCE_TRANSACTION_RESOURCE_NAME,
BILLING_CREDIT_BALANCE_SUMMARY_RESOURCE_NAME,
BILLING_CREDIT_BALANCE_TRANSACTION_RESOURCE_NAME,
BILLING_CREDIT_GRANT_RESOURCE_NAME,
@@ -1152,6 +1153,7 @@ class TestWebhookEventMapping:
@parameterized.expand(
[
+ (BALANCE_TRANSACTION_RESOURCE_NAME,),
(SUBSCRIPTION_ITEM_RESOURCE_NAME,),
(SETUP_ATTEMPT_RESOURCE_NAME,),
(SHIPPING_RATE_RESOURCE_NAME,),
@@ -1684,6 +1686,9 @@ class TestSchemaWebhookCapability:
expected = name in RESOURCE_TO_STRIPE_WEBHOOK_EVENT or schema.webhook_only
assert schema.supports_webhooks is expected, name
+ def test_balance_transaction_does_not_offer_webhook_sync(self):
+ assert self.by_name[BALANCE_TRANSACTION_RESOURCE_NAME].supports_webhooks is False
+
class TestCreateWebhookPermissionErrorCopy:
# Regression test: a permission-denied webhook creation used to always tell the user to add
diff --git a/products/warehouse_sources/backend/tests/api/test_external_data_schema.py b/products/warehouse_sources/backend/tests/api/test_external_data_schema.py
index 0b9cccc892f8..5d681b44da7a 100644
--- a/products/warehouse_sources/backend/tests/api/test_external_data_schema.py
+++ b/products/warehouse_sources/backend/tests/api/test_external_data_schema.py
@@ -157,7 +157,7 @@ class TestExternalDataSchema(APIBaseTest):
"cdc_available": None,
"xmin_available": None,
"full_refresh_available": True,
- "supports_webhooks": True,
+ "supports_webhooks": False,
"webhook_only": False,
"available_columns": [],
"detected_primary_keys": None,