: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): surface friendly error when source validation hits a config issue (#65988)
Tom Owersdc51dd048205
diff --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 30ef84d791d5..e850e5921020 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@@ -269,7 +269,15 @@ If automatic creation failed, your token needs webhook permissions — the **admaccess_token = self._get_access_token(config, team_id)return validate_github_credentials(access_token, config.repository)except Exception as e:- return False, str(e)+ # `_get_access_token` and the OAuth mixin raise deterministic config/credential errors+ # (missing integration ID, missing token, integration deleted). The user-facing wording+ # already lives in `get_non_retryable_errors`; reuse it so this path doesn't leak the+ # internal developer string to the wizard. Fall back to the raw message if unmapped.+ raw = str(e)+ for pattern, friendly in self.get_non_retryable_errors().items():+ if friendly and pattern in raw:+ return False, friendly+ return False, rawdef get_resumable_source_manager(self, inputs: SourceInputs) -> ResumableSourceManager[GithubResumeConfig]:return ResumableSourceManager[GithubResumeConfig](inputs, GithubResumeConfig)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 dcab4800db9d..38048eb00974 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@@ -110,3 +110,25 @@ class TestGithubSource:self.source._get_access_token(config, self.team_id)assert "GitHub access token not found" in self.source.get_non_retryable_errors()++ @pytest.mark.parametrize(+ "selection,expected_message",+ [+ ("oauth", "No GitHub account is connected. Please reconnect your GitHub account."),+ ("pat", "GitHub personal access token is not configured. Please update the source configuration."),+ ],+ )+ def test_validate_credentials_maps_config_errors_to_friendly_message(self, selection, expected_message):+ config = GithubSourceConfig(+ auth_method=GithubAuthMethodConfig(+ github_integration_id=None, selection=selection, personal_access_token=""+ ),+ repository="owner/repo",+ )++ valid, message = self.source.validate_credentials(config, self.team_id)++ assert valid is False+ # The wizard surfaces this string directly, so it must be the friendly copy, not the+ # internal "Missing ..." developer string raised by `_get_access_token`.+ assert message == expected_message