: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 Instagram API version v22.0 (#113214)
Tom Owers8518720b538c
diff --git a/products/warehouse_sources/backend/migrations/0181_repin_instagram_api_version.py b/products/warehouse_sources/backend/migrations/0181_repin_instagram_api_version.pynew file mode 100644index 000000000000..da62cb101e52--- /dev/null+++ b/products/warehouse_sources/backend/migrations/0181_repin_instagram_api_version.py@@ -0,0 +1,36 @@+from django.db import migrations++# Meta's Graph API v22.0 is deprecated and the vendor stops serving it on 2027-05-20. Meta does not+# reject a call on a retired version; it upgrades the call to the oldest version still served, so a+# pin left behind moves silently instead of failing. Repin source-level pins onto v26.0 (the current+# default). The versions differ only in the URL version segment the source sends: the edges, fields,+# pagination, and response handling this source uses are identical across them, so the repin needs+# no data/schema transform — only the pin moves.+INSTAGRAM_SOURCE_TYPE = "Instagram"+DEPRECATED_VERSION = "v22.0"+TARGET_VERSION = "v26.0"+++def repin_instagram_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), and v23.0 pins are still served, so both stay put. 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=INSTAGRAM_SOURCE_TYPE, api_version=DEPRECATED_VERSION).update(+ api_version=TARGET_VERSION+ )+++class Migration(migrations.Migration):+ dependencies = [+ ("warehouse_sources", "0180_repin_incident_io_api_version_v3"),+ ]++ 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_instagram_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.txtindex eef74519a7e0..bcf64551730b 100644--- a/products/warehouse_sources/backend/migrations/max_migration.txt+++ b/products/warehouse_sources/backend/migrations/max_migration.txt@@ -1 +1 @@-0180_repin_incident_io_api_version_v3+0181_repin_instagram_api_versiondiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/instagram/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/instagram/source.pyindex b7f9e42dca5e..6c0738122cca 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/instagram/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/instagram/source.py@@ -1,3 +1,4 @@+from datetime import datefrom typing import Optional, castimport structlog@@ -13,7 +14,11 @@ from products.warehouse_sources.backend.facade.source_config import (SourceFieldOauthAccountSelectConfig,SourceFieldOauthConfig,)-from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import FieldType, ResumableSource+from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import (+ FieldType,+ ResumableSource,+ VersionDeprecation,+)from products.warehouse_sources.backend.temporal.data_imports.sources.common.canonical_descriptions import (CanonicalDescriptions,)@@ -59,6 +64,7 @@ class InstagramSource(ResumableSource[InstagramSourceConfig, InstagramResumeConf# roughly two years, so the pin is a real choice rather than a constant.supported_versions = ("v22.0", "v23.0", "v26.0")default_version = "v26.0"+ deprecated_versions = (VersionDeprecation(version="v22.0", sunset_at=date(2027, 5, 20)),)lists_tables_without_credentials = Truediff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/instagram/tests/test_instagram_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/instagram/tests/test_instagram_source.pyindex 89d5cc595494..7b3601a4eb19 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/instagram/tests/test_instagram_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/instagram/tests/test_instagram_source.py@@ -1,3 +1,4 @@+from datetime import datefrom typing import Anyimport pytest@@ -6,6 +7,7 @@ from unittest import mockimport structlogfrom products.warehouse_sources.backend.facade.source_config import SourceFieldOauthConfig+from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import VersionDeprecationfrom products.warehouse_sources.backend.temporal.data_imports.sources.common.integration_accounts import (IntegrationAccountListingError,)@@ -75,6 +77,9 @@ class TestInstagramSource:assert self.source.resolve_api_version(None) == "v26.0"# An existing pin is honored verbatim so older sources keep hitting their own version path.assert self.source.resolve_api_version("v23.0") == "v23.0"+ # Meta stops serving v22.0 on 2027-05-20; it stays supported until then so pinned rows keep syncing.+ assert "v22.0" in self.source.supported_versions+ assert self.source.deprecated_versions == (VersionDeprecation(version="v22.0", sunset_at=date(2027, 5, 20)),)assert self.source.api_docs_url is not None and self.source.api_docs_url.startswith("https://")def test_fan_out_tables_key_on_the_parent_so_rows_stay_unique_table_wide(self) -> None: