: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 Github API version 2022-11-28 (#86335)
Tom Owersb9adddbc14ec
diff --git a/products/warehouse_sources/backend/migrations/0155_repin_github_api_version.py b/products/warehouse_sources/backend/migrations/0155_repin_github_api_version.pynew file mode 100644index 000000000000..2f77fbb29b6c--- /dev/null+++ b/products/warehouse_sources/backend/migrations/0155_repin_github_api_version.py@@ -0,0 +1,36 @@+from django.db import migrations++# GitHub is deprecating the 2022-11-28 REST API version (its X-GitHub-Api-Version header value),+# which returns 410 Gone at least 24 months after the 2026-03-10 release. This repins existing+# source-level pins from "2022-11-28" to "2026-03-10" (the current default) so they stop sending a+# header GitHub will stop accepting. The response shapes GitHub serves for the endpoints this source+# reads are unchanged across the two versions, so only the pin moves — no data/schema transform.+SOURCE_TYPE = "Github"+DEPRECATED_VERSION = "2022-11-28"+NEW_VERSION = "2026-03-10"+++def repin_github_2022_to_2026(apps, schema_editor):+ ExternalDataSource = apps.get_model("warehouse_sources", "ExternalDataSource")++ # Source-level pin only. Schema-level `ExternalDataSchema.api_version` overrides are user-managed+ # (a customer intentionally pinned that schema) and are left alone — the schema-level deprecation+ # banner prompts the user to migrate those.+ #+ # NULL pins already resolve to the source's `default_version` (already "2026-03-10"), so they need+ # no update. Matching only `api_version="2022-11-28"` keeps this idempotent: a second run matches+ # nothing. ExternalDataSource is one row per configured source, so a single bulk update is quick.+ ExternalDataSource.objects.filter(source_type=SOURCE_TYPE, api_version=DEPRECATED_VERSION).update(+ api_version=NEW_VERSION+ )+++class Migration(migrations.Migration):+ dependencies = [("warehouse_sources", "0154_repin_mem0_api_version")]++ operations = [+ # Reverse is a no-op: once repinned, these rows are indistinguishable from natively-created+ # ones, so a blanket downgrade would clobber legitimate "2026-03-10" pins and move customers+ # back onto the sunset header.+ migrations.RunPython(repin_github_2022_to_2026, 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 1602eb5aebf0..df8b62e1ba7f 100644--- a/products/warehouse_sources/backend/migrations/max_migration.txt+++ b/products/warehouse_sources/backend/migrations/max_migration.txt@@ -1 +1 @@-0154_repin_mem0_api_version+0155_repin_github_api_versiondiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/github/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/github/source.pyindex 9290272562b5..e98d840ab13f 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/github/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/github/source.py@@ -1,4 +1,5 @@import secrets+import datetimefrom collections.abc import Callablefrom concurrent.futures import ThreadPoolExecutorfrom typing import TYPE_CHECKING, Any, Optional, TypeVar, cast@@ -26,6 +27,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.basExternalWebhookInfo,FieldType,ResumableSource,+ VersionDeprecation,WebhookCreationResult,WebhookDeletionResult,WebhookSource,@@ -141,6 +143,10 @@ class GithubSource(supported_versions = ("2022-11-28", "2026-03-10")default_version = "2026-03-10"api_docs_url = "https://docs.github.com/en/rest/about-the-rest-api/api-versions"+ # GitHub keeps a REST API version answerable for at least 24 months after the next one ships,+ # then returns 410 Gone. 2022-11-28 is superseded by the 2026-03-10 default, so its earliest+ # sunset is 2028-03-10 (24 months after that release).+ deprecated_versions = (VersionDeprecation(version="2022-11-28", sunset_at=datetime.date(2028, 3, 10)),)@propertydef source_type(self) -> ExternalDataSourceType:@@ -309,6 +315,11 @@ If automatic creation failed with a permissions error, the fix depends on how yo# deleted repository or one the connection can no longer see."GitHub repository is not accessible": "This repository is no longer available on GitHub. It may have been deleted, or your connection may have lost access to it. Update the source with a repository you can still reach, or reconnect your GitHub account.","404 Client Error": "GitHub couldn't find this repository. Check that it still exists and that your connection can access it.",+ # Every GitHub call carries the source's pinned version in the X-GitHub-Api-Version+ # header, and GitHub answers 410 Gone once a version is sunset (2022-11-28 reaches this+ # 24 months after the 2026-03-10 release). 410 is permanent, so retrying loops forever;+ # disable the schema and point the user at the version repin instead.+ "410 Client Error": "GitHub no longer serves the API version this source is pinned to. Update the source to a supported version, then sync again.","Bad credentials": "Your GitHub connection is invalid or expired. Please reconnect.",# The GitHub App isn't configured on this PostHog instance, so an OAuth source can't mint# the App JWT to refresh its installation token. Deterministic — retrying never resolves it.diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/github/tests/test_github_source_class.py b/products/warehouse_sources/backend/temporal/data_imports/sources/github/tests/test_github_source_class.pyindex 1a149b5b8c73..2e8e04f58298 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/github/tests/test_github_source_class.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/github/tests/test_github_source_class.py@@ -1,3 +1,5 @@+import datetime+import pytestfrom unittest import mock@@ -115,11 +117,23 @@ class TestGithubSource:"Integration not found","Missing integration ID","This installation has been suspended",+ # A sunset API version pinned in X-GitHub-Api-Version returns 410 Gone permanently, so it+ # must disable the schema rather than retry forever.+ "410 Client Error",],)def test_non_retryable_errors(self, expected_key):assert expected_key in self.source.get_non_retryable_errors()+ def test_deprecated_api_version_metadata(self):+ # The generic registry test only checks deprecated ⊆ supported and default ∉ deprecated; this+ # locks GitHub's specific deprecation — 2022-11-28 sunset on 2028-03-10, 2026-03-10 current —+ # which drives the in-product warning and the source-level repin migration.+ deprecation = self.source.get_version_deprecation("2022-11-28")+ assert deprecation is not None+ assert deprecation.sunset_at == datetime.date(2028, 3, 10)+ assert self.source.get_version_deprecation("2026-03-10") is None+def test_rate_limit_error_is_retryable_not_non_retryable(self):# A GitHubRateLimitError that exhausts _fetch_page's tenacity retry must stay retryable# so it never gets classified as a permanent failure that disables the source.