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.

feat(warehouse_sources): deprecate Meta Ads API v25.0, repin to v26.0 (#86325)

Tom Owers51876408d101
diff --git a/products/warehouse_sources/backend/migrations/0153_repin_meta_ads_api_version.py b/products/warehouse_sources/backend/migrations/0153_repin_meta_ads_api_version.py
new file mode 100644
index 000000000000..c5a3d586a0ce
--- /dev/null
+++ b/products/warehouse_sources/backend/migrations/0153_repin_meta_ads_api_version.py
@@ -0,0 +1,34 @@
+from django.db import migrations
+
+# Meta's Graph API v25.0 entered its deprecated phase and the vendor sunsets it on 2028-07-29.
+# Repin source-level pins onto v26.0. Both versions differ only in the URL version segment the
+# source sends; the endpoints, fields, and response shapes this source reads are identical across
+# them, so the repin needs no data/schema transform — only the pin moves.
+META_ADS_SOURCE_TYPE = "MetaAds"
+DEPRECATED_VERSION = "v25.0"
+TARGET_VERSION = "v26.0"
+
+
+def repin_meta_ads_api_version(apps, schema_editor):
+ ExternalDataSource = apps.get_model("warehouse_sources", "ExternalDataSource")
+
+ # Only touch source-level pins still on the deprecated version. NULL pins already resolve to the
+ # source's `default_version` (v26.0), so they need no update. Filtering on the exact old value
+ # keeps this idempotent — a re-run matches nothing. Schema-level overrides
+ # (`ExternalDataSchema.api_version`) are intentionally customer-pinned and are left untouched.
+ ExternalDataSource.objects.filter(source_type=META_ADS_SOURCE_TYPE, api_version=DEPRECATED_VERSION).update(
+ api_version=TARGET_VERSION
+ )
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("warehouse_sources", "0152_callable_choices"),
+ ]
+
+ operations = [
+ # Reverse is a no-op: once repinned, a source on v26.0 is indistinguishable from one
+ # natively created on the new default, so downgrading every v26.0 row would clobber
+ # legitimate native pins.
+ migrations.RunPython(repin_meta_ads_api_version, migrations.RunPython.noop, elidable=True),
+ ]
diff --git a/products/warehouse_sources/backend/migrations/max_migration.txt b/products/warehouse_sources/backend/migrations/max_migration.txt
index ebb653a306b0..b3e13f787a62 100644
--- a/products/warehouse_sources/backend/migrations/max_migration.txt
+++ b/products/warehouse_sources/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0152_callable_choices
+0153_repin_meta_ads_api_version
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/meta_ads/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/meta_ads/source.py
index f23114fce694..92547df4a8a8 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/meta_ads/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/meta_ads/source.py
@@ -1,3 +1,4 @@
+from datetime import date
from typing import cast
from posthog.schema import (
@@ -20,6 +21,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.bas
MARKETING_ANALYTICS_SUGGESTED_TABLE_TOOLTIP,
FieldType,
ResumableSource,
+ VersionDeprecation,
)
from products.warehouse_sources.backend.temporal.data_imports.sources.common.canonical_descriptions import (
CanonicalDescriptions,
@@ -87,6 +89,7 @@ class MetaAdsSource(ResumableSource[MetaAdsSourceConfig, MetaAdsResumeConfig], O
supported_versions = (META_ADS_API_VERSION_V25, META_ADS_API_VERSION_V26)
default_version = META_ADS_API_VERSION_V26
api_docs_url = "https://developers.facebook.com/docs/graph-api/changelog"
+ deprecated_versions = (VersionDeprecation(version=META_ADS_API_VERSION_V25, sunset_at=date(2028, 7, 29)),)
@property
def source_type(self) -> ExternalDataSourceType:
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/meta_ads/test_meta_ads.py b/products/warehouse_sources/backend/temporal/data_imports/sources/meta_ads/test_meta_ads.py
index 8d58d0d2244e..215dff70fe7b 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/meta_ads/test_meta_ads.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/meta_ads/test_meta_ads.py
@@ -13,6 +13,7 @@ from requests.exceptions import (
JSONDecodeError as RequestsJSONDecodeError,
)
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import VersionDeprecation
from products.warehouse_sources.backend.temporal.data_imports.sources.common.integration_accounts import (
IntegrationAccountListingError,
)
@@ -2004,3 +2005,14 @@ class TestApiVersionDispatch:
def test_new_sources_default_to_latest_while_previous_stays_supported(self) -> None:
assert MetaAdsSource.default_version == META_ADS_API_VERSION_V26
assert set(MetaAdsSource.supported_versions) == {META_ADS_API_VERSION_V25, META_ADS_API_VERSION_V26}
+
+ def test_v25_is_deprecated_with_vendor_sunset_date(self) -> None:
+ # The deprecation metadata (not just membership in `supported_versions`) drives the
+ # in-product warning banner and the sunset countdown, so lock in the exact version and date.
+ source = MetaAdsSource()
+ assert source.get_version_deprecation(META_ADS_API_VERSION_V25) == VersionDeprecation(
+ version=META_ADS_API_VERSION_V25, sunset_at=dt.date(2028, 7, 29)
+ )
+ # The default must never be deprecated — a pinned-off-default warning on every new source
+ # would be the drift the framework prevents.
+ assert source.get_version_deprecation(META_ADS_API_VERSION_V26) is None