: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(braintree): select subscription amounts as scalar fields (#110076)
Kyle Swank8bb38d2f1baf
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/braintree/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/braintree/canonical_descriptions.pyindex 4cc5fd84ecbb..5e98f33a239c 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/braintree/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/braintree/canonical_descriptions.py@@ -76,9 +76,9 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"planId": "Identifier of the plan the subscription is based on.","merchantAccountId": "Identifier of the merchant account used for the subscription.","paymentMethodId": "Identifier of the payment method charged for the subscription.",- "price": "Base price and currency for this subscription.",- "balance": "Outstanding charges associated with the subscription.",- "nextBillingPeriodAmount": "Total amount for the next billing period, including add-ons and discounts but not the current balance.",+ "price": "Base price for this subscription, as a decimal string in the merchant account's currency.",+ "balance": "Outstanding charges associated with the subscription, as a decimal string in the merchant account's currency.",+ "nextBillingPeriodAmount": "Total amount for the next billing period, including add-ons and discounts but not the current balance, as a decimal string in the merchant account's currency.","billingDayOfMonth": "Day of the month the subscription is charged on in every billing cycle.","currentBillingCycle": "The subscription's current billing cycle, incremented at the end of each billing period.","numberOfBillingCycles": "Number of billing cycles to execute; 0 means the subscription never expires.",diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/braintree/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/braintree/settings.pyindex df119a819610..1203c66fa423 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/braintree/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/braintree/settings.py@@ -58,6 +58,9 @@ _CUSTOMER_FIELDS = """website"""+# `price`, `balance` and `nextBillingPeriodAmount` are the `Amount` scalar (a decimal+# string), not the `MonetaryAmount` object the other streams select `{ value currencyCode }`+# on — a subselection here fails GraphQL validation for the whole query._RECURRING_BILLING_SUBSCRIPTION_FIELDS = """idlegacyId@@ -65,9 +68,9 @@ _RECURRING_BILLING_SUBSCRIPTION_FIELDS = """planIdmerchantAccountIdpaymentMethodId- price { value currencyCode }- balance { value currencyCode }- nextBillingPeriodAmount { value currencyCode }+ price+ balance+ nextBillingPeriodAmountbillingDayOfMonthcurrentBillingCyclenumberOfBillingCyclesdiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/braintree/tests/test_braintree.py b/products/warehouse_sources/backend/temporal/data_imports/sources/braintree/tests/test_braintree.pyindex ccc4c2e7b6fb..7ac037d53b82 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/braintree/tests/test_braintree.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/braintree/tests/test_braintree.py@@ -1,3 +1,4 @@+import refrom datetime import UTC, date, datetimefrom typing import Any@@ -81,6 +82,14 @@ class TestBuildQuery:assert f"$input: {input_type}!" in queryassert BRAINTREE_ENDPOINTS[endpoint].connection_field in query+ @pytest.mark.parametrize("field", ["price", "balance", "nextBillingPeriodAmount"])+ def test_subscription_amounts_are_selected_as_leaves(self, field):+ # These are Braintree's `Amount` scalar; a subselection fails validation+ # (SubselectionNotAllowed) and rejects the whole query.+ query = _build_query(BRAINTREE_ENDPOINTS["recurring_billing_subscriptions"])+ assert re.search(rf"\b{field}\b", query)+ assert not re.search(rf"\b{field}\s*{{", query)+def test_query_nests_connection_under_its_wrappers(self):# `merchantAccounts` hangs off `viewer.merchant`, not the `search` root.query = _build_query(BRAINTREE_ENDPOINTS["merchant_accounts"])