: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
feat(warehouse_sources): deprecate Google Ads API v23 (#80094)
Tom Owers0863be71a915
diff --git a/.agents/skills/warehouse-source-new-version/SKILL.md b/.agents/skills/warehouse-source-new-version/SKILL.mdindex 1dd4ca9fc655..3f1c40544da8 100644--- a/.agents/skills/warehouse-source-new-version/SKILL.md+++ b/.agents/skills/warehouse-source-new-version/SKILL.md@@ -65,7 +65,7 @@ Add it when any of these hold:2. Add the old version to `deprecated_versions` with the vendor's announced sunset date (or `sunset_at=None` if none). Never deprecate `default_version` — flip the default to the new version in the same PR.3. The in-product warning banner and API fields light up automatically from the metadata — zero per-source UI work.4. **Deprecated is not migrated.** Existing pins move only when the vendor has announced the version will stop being served (a sunset/removal date). A deprecation without a sunset date is advisory: mark it, leave every existing pin on it fully supported, and write no migration — repinning working customers off a version the vendor still serves is exactly the silent version move the pinning framework exists to prevent. Two narrow cases still repin under an advisory (`sunset_at=None`) deprecation: the deprecated label resolves to a byte-identical request as the new default (a pure alias — no per-version dispatch — so the repin is not a move), or the vendor already errors on the old version (e.g. `410`/`406`) so leaving pins is worse than moving them. A source that sends a per-version header/URL for a version the vendor still serves is neither — stay advisory.-5. Only for a sunsetting version: include a **written-not-run** migration script that repins affected `ExternalDataSource` rows (`api_version` column) from the deprecated version to the new one, plus any safe data/schema transforms. It must be idempotent and reviewable, and its reverse must be a no-op — repinned rows are indistinguishable from natively-created ones, so a blanket downgrade would clobber legitimate native pins. Where migration is lossy or unsafe — including when the new version needs credentials that can't be derived from the stored ones — do not script it: document the manual path in the PR. Do not execute migrations or backfills; humans review and run them.+5. Only for a sunsetting version: include a **written-not-run** migration script that repins affected `ExternalDataSource` rows (`api_version` column) from the deprecated version to the new one, plus any safe data/schema transforms. It must be idempotent and reviewable, and its reverse must be a no-op — repinned rows are indistinguishable from natively-created ones, so a blanket downgrade would clobber legitimate native pins. Repin only rows explicitly on the deprecated version: when the default is already the target (you are deprecating an old label without flipping the default in this PR), do not also repin NULL pins — they already resolve to the current default, so touching them is redundant churn — and leave other still-served deprecated versions alone. Where migration is lossy or unsafe — including when the new version needs credentials that can't be derived from the stored ones — do not script it: document the manual path in the PR. Do not execute migrations or backfills; humans review and run them.6. **Never touch `ExternalDataSchema.api_version` overrides** in migration scripts — they are user-managed by design. The schema-level deprecation warning covers them; the user migrates them from the schema's configuration page.## Pinning semantics (do not break these)diff --git a/products/warehouse_sources/backend/migrations/0132_repin_google_ads_api_version.py b/products/warehouse_sources/backend/migrations/0132_repin_google_ads_api_version.pynew file mode 100644index 000000000000..a998fe9a8cdc--- /dev/null+++ b/products/warehouse_sources/backend/migrations/0132_repin_google_ads_api_version.py@@ -0,0 +1,33 @@+from django.db import migrations++# Google is sunsetting the Google Ads API v23 (scheduled February 2027) in favor of v25, the current+# default. This repins the source-level pin only, and only for rows explicitly on v23: NULL pins+# already resolve to the v25 default (the default is not flipped here), and v24 pins stay on v24 —+# Google still serves v24, so moving them is a separate, later decision. The request layer already+# supports v23/v24/v25; on the next sync a repinned source rediscovers its schemas under v25 via the+# version-aware discovery path, and merge-by-primary-key keeps that idempotent, so no data transform+# is scripted here. Schema-level `ExternalDataSchema.api_version` overrides are user-managed by design+# and intentionally left untouched — the schema-level deprecation banner prompts those migrations.+SOURCE_TYPE = "GoogleAds"+DEPRECATED_VERSION = "v23"+NEW_VERSION = "v25"+++def repin_google_ads_to_v25(apps, schema_editor):+ ExternalDataSource = apps.get_model("warehouse_sources", "ExternalDataSource")++ # ExternalDataSource is one row per configured source (thousands, not events-scale), so a single+ # bulk update in the migration's transaction is quick. Idempotent: a second run finds no v23 rows.+ ExternalDataSource.objects.filter(source_type=SOURCE_TYPE, api_version=DEPRECATED_VERSION).update(+ api_version=NEW_VERSION+ )+++class Migration(migrations.Migration):+ dependencies = [("warehouse_sources", "0131_pin_leadfeeder_null_api_version_to_v1")]++ operations = [+ # Reverse is a no-op: once repinned, v25 rows are indistinguishable from natively-created ones,+ # so a blanket downgrade would clobber legitimate v25 pins made after this ran.+ migrations.RunPython(repin_google_ads_to_v25, migrations.RunPython.noop, elidable=True),+ ]diff --git a/products/warehouse_sources/backend/migrations/max_migration.txt b/products/warehouse_sources/backend/migrations/max_migration.txtindex f721b6eb2cb9..0075dd16bbc3 100644--- a/products/warehouse_sources/backend/migrations/max_migration.txt+++ b/products/warehouse_sources/backend/migrations/max_migration.txt@@ -1 +1 @@-0131_pin_leadfeeder_null_api_version_to_v1+0132_repin_google_ads_api_versiondiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/google_ads/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/google_ads/source.pyindex 92d2e7e4d713..240911f9007b 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/google_ads/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/google_ads/source.py@@ -1,4 +1,5 @@import re+import datetimefrom typing import Optional, castfrom django.core.cache import cache@@ -84,11 +85,15 @@ class GoogleAdsSource(supported_versions = ("v23", "v24", "v25")default_version = "v25"api_docs_url = "https://developers.google.com/google-ads/api/docs/release-notes"- # Google sunsets each major ~12 months after release; v24 (released 2026-04-22) is projected- # for ~May 2027 but has no firm date on the sunset page yet, so `sunset_at` stays None until- # Google publishes one. Existing v24 pins stay on v24 until then — Google still serves it, and- # the repin belongs in the PR that records the real sunset date.- deprecated_versions = (VersionDeprecation(version="v24", sunset_at=None),)+ # Google sunsets each major ~12 months after release. v23 (released 2026-01-28) is scheduled to+ # sunset in February 2027; Google has announced the month but not the exact day, so pin the+ # conservative first-of-month — the deprecation banner and the v23→v25 repin migration key off it.+ # v24 (released 2026-04-22) is projected for ~May 2027 with no firm date on the sunset page yet,+ # so its `sunset_at` stays None until Google publishes one and existing v24 pins stay on v24.+ deprecated_versions = (+ VersionDeprecation(version="v23", sunset_at=datetime.date(2027, 2, 1)),+ VersionDeprecation(version="v24", sunset_at=None),+ )@propertydef source_type(self) -> ExternalDataSourceType:diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/google_ads/tests/test_google_ads_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/google_ads/tests/test_google_ads_source.pyindex a756171c17c1..f5c4804a00cb 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/google_ads/tests/test_google_ads_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/google_ads/tests/test_google_ads_source.py@@ -1556,9 +1556,16 @@ class TestVersionDeclaration:assert source.default_version == "v25"assert set(source.supported_versions) == {"v23", "v24", "v25"}+ def test_v23_deprecated_with_sunset_date(self):+ # v23 is sunsetting (February 2027), so it must carry both the deprecation flag and the sunset+ # date — the in-product banner shows the date and the v23→v25 repin migration is justified by it.+ v23_deprecation = GoogleAdsSource().get_version_deprecation("v23")+ assert v23_deprecation is not None+ assert v23_deprecation.sunset_at == dt.date(2027, 2, 1)+def test_v24_deprecated_default_is_not(self):- # v24 is the version the vendor is retiring, so it must carry the deprecation flag that drives- # the in-product warning; the current default (v25) must never be deprecated.+ # v24 is also deprecated but has no announced sunset date yet, so it must carry the flag with a+ # None sunset; the current default (v25) must never be deprecated.source = GoogleAdsSource()v24_deprecation = source.get_version_deprecation("v24")assert v24_deprecation is not None