: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
fix(github): treat GitHub App not configured as non-retryable (#63747)
Tom Owersa942954e7080
diff --git a/posthog/temporal/data_imports/sources/github/source.py b/posthog/temporal/data_imports/sources/github/source.pyindex 1521bd354ff4..31de831a076e 100644--- a/posthog/temporal/data_imports/sources/github/source.py+++ b/posthog/temporal/data_imports/sources/github/source.py@@ -108,6 +108,10 @@ class GithubSource(ResumableSource[GithubSourceConfig, GithubResumeConfig], OAut"403 Client Error": "Access forbidden. Your token may lack required permissions or have hit rate limits.","404 Client Error": "Repository not found. Please verify the repository name and access permissions.","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.+ "GITHUB_APP_CLIENT_ID is not configured": "The GitHub App is not configured on this PostHog instance. Please contact support.",+ "GITHUB_APP_PRIVATE_KEY is not configured": "The GitHub App is not configured on this PostHog instance. Please contact support.",}def _get_access_token(self, config: GithubSourceConfig, team_id: int) -> str:diff --git a/posthog/temporal/tests/data_imports/github/test_github_source.py b/posthog/temporal/tests/data_imports/github/test_github_source.pyindex 7d82f91140c4..91d9ca3cd9fb 100644--- a/posthog/temporal/tests/data_imports/github/test_github_source.py+++ b/posthog/temporal/tests/data_imports/github/test_github_source.py@@ -22,6 +22,9 @@ from posthog.temporal.data_imports.sources.github.github import (validate_credentials,)from posthog.temporal.data_imports.sources.github.settings import GITHUB_ENDPOINTS+from posthog.temporal.data_imports.sources.github.source import GithubSource++from products.data_warehouse.backend.types import ExternalDataSourceTypedef _make_response(status: int = 200, body: Any = None, link: str = "") -> mock.Mock:@@ -795,3 +798,43 @@ class _ChunkingBatcher:self._buffer = []return tableraise Exception("No chunks available to yield")+++class TestGithubSourceNonRetryableErrors:+ def setup_method(self) -> None:+ self.source = GithubSource()++ def test_source_type(self) -> None:+ assert self.source.source_type == ExternalDataSourceType.GITHUB++ @parameterized.expand(+ [+ ("401",),+ ("403",),+ ("404",),+ ("bad_credentials",),+ ("client_id_not_configured",),+ ("private_key_not_configured",),+ ]+ )+ def test_non_retryable_errors_contains_key(self, _name: str) -> None:+ expected_keys = {+ "401": "401 Client Error",+ "403": "403 Client Error",+ "404": "404 Client Error",+ "bad_credentials": "Bad credentials",+ "client_id_not_configured": "GITHUB_APP_CLIENT_ID is not configured",+ "private_key_not_configured": "GITHUB_APP_PRIVATE_KEY is not configured",+ }+ assert expected_keys[_name] in self.source.get_non_retryable_errors()++ @parameterized.expand(+ [+ ("[ErrorDetail(string='GITHUB_APP_CLIENT_ID is not configured', code='invalid')]",),+ ("[ErrorDetail(string='GITHUB_APP_PRIVATE_KEY is not configured', code='invalid')]",),+ ]+ )+ def test_app_not_configured_is_recognised_as_non_retryable(self, internal_error: str) -> None:+ # Mirrors the substring match done in external_data_job.update_external_data_job_model.+ non_retryable_errors = self.source.get_non_retryable_errors()+ assert any(pattern in internal_error for pattern in non_retryable_errors)