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.

fix(github): skip plan-gated repository features instead of failing the table (#120163)

Tom Owers6fe41bc3d766
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/github/github.py b/products/warehouse_sources/backend/temporal/data_imports/sources/github/github.py
index 9f08723570e3..2400c022cebf 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/github/github.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/github/github.py
@@ -779,9 +779,19 @@ def _github_error_message(response: requests.Response) -> str:
# GitHub answers 403 both for a real permission denial and for a repository feature the owner has
# switched off — Dependabot alerts disabled, code scanning without Advanced Security, an archived
-# repository. A switched-off feature has nothing to sync now or on any later run, so it is a
-# zero-row skip rather than something to fail the schema over. Matched against GitHub's own message.
-_FEATURE_UNAVAILABLE_MARKERS = ("is disabled", "are disabled", "must be enabled", "not enabled", "is archived")
+# repository. It also answers 403 for a feature its plan gates, such as rulesets on a private
+# repository under a free plan ("Upgrade to GitHub Pro or make this repository public to enable this
+# feature."). A switched-off or plan-gated feature has nothing to sync until the owner changes the
+# repository, so it is a zero-row skip rather than something to fail the schema over. Matched
+# against GitHub's own message.
+_FEATURE_UNAVAILABLE_MARKERS = (
+ "is disabled",
+ "are disabled",
+ "must be enabled",
+ "not enabled",
+ "is archived",
+ "to enable this feature",
+)
def _is_feature_unavailable_denial(message: str) -> bool:
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/github/tests/test_github_fetch_page.py b/products/warehouse_sources/backend/temporal/data_imports/sources/github/tests/test_github_fetch_page.py
index 31912ed3c037..5a1be6620545 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/github/tests/test_github_fetch_page.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/github/tests/test_github_fetch_page.py
@@ -355,6 +355,10 @@ def _error_response(status_code: int, message: str, headers: dict[str, str] | No
github.GithubResourceUnavailableError,
),
("Secret scanning is disabled on this repository.", github.GithubResourceUnavailableError),
+ (
+ "Upgrade to GitHub Pro or make this repository public to enable this feature.",
+ github.GithubResourceUnavailableError,
+ ),
# A real denial stays fatal, and carries GitHub's own reason so the curated copy can name it.
("Resource not accessible by integration", github.GithubAccessDeniedError),
("Must have admin rights to Repository.", github.GithubAccessDeniedError),