: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(warehouse_sources): clean up Sentry connect error copy (#90667)
Tom Owersed717720facc
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/sentry/sentry.py b/products/warehouse_sources/backend/temporal/data_imports/sources/sentry/sentry.pyindex 1b84e0c1bb88..4ed5dd5daa00 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/sentry/sentry.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/sentry/sentry.py@@ -1136,14 +1136,15 @@ def validate_credentials(+ ".",)if response.status_code == 404:- return False, f"Sentry organization '{organization_slug}' not found"+ return False, "Sentry organization not found. Verify your organization slug, then reconnect."- try:- return False, response.json().get("detail", response.text)- except Exception:- return False, response.text+ # Keep the vendor detail in logs for debugging, but never surface it — the raw body can+ # echo the org slug or unrelated Sentry internals back to the customer.+ logger.warning("sentry_source.validate_credentials_unexpected_status", status_code=response.status_code)+ return False, "Could not connect to Sentry. Check your auth token and organization slug, then reconnect."except RequestException as exc:- return False, str(exc)+ logger.warning("sentry_source.validate_credentials_request_error", error=str(exc))+ return False, "Could not reach Sentry to validate your credentials. Check your connection, then try again."# ---------------------------------------------------------------------------diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/sentry/tests/test_sentry.py b/products/warehouse_sources/backend/temporal/data_imports/sources/sentry/tests/test_sentry.pyindex c98ccf7d4bf6..c915fe673fb1 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/sentry/tests/test_sentry.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/sentry/tests/test_sentry.py@@ -5,7 +5,7 @@ import pytestfrom unittest.mock import Mock, patchfrom parameterized import parameterized-from requests.exceptions import HTTPError, JSONDecodeError+from requests.exceptions import HTTPError, JSONDecodeError, RequestExceptionfrom products.warehouse_sources.backend.temporal.data_imports.sources.common.base import error_message_matchesfrom products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.warehouse_parent import (@@ -327,6 +327,35 @@ class TestSentryTransport:for scope in REQUIRED_SENTRY_SCOPES:assert scope in error+ @patch("products.warehouse_sources.backend.temporal.data_imports.sources.sentry.sentry.make_tracked_session")+ def test_validate_credentials_404_does_not_echo_org_slug(self, mock_session) -> None:+ mock_session.return_value.get.return_value = _response(None, status_code=404)++ valid, error = validate_credentials(auth_token="token", organization_slug="secret-org-slug")++ assert not valid+ assert error == "Sentry organization not found. Verify your organization slug, then reconnect."+ assert "secret-org-slug" not in (error or "")++ @patch("products.warehouse_sources.backend.temporal.data_imports.sources.sentry.sentry.make_tracked_session")+ def test_validate_credentials_unexpected_status_hides_vendor_detail(self, mock_session) -> None:+ # `_response` sets `response.text = "error"` — the raw body must never reach the customer.+ mock_session.return_value.get.return_value = _response({"detail": "internal sentry detail"}, status_code=500)++ valid, error = validate_credentials(auth_token="token", organization_slug="acme")++ assert not valid+ assert error == "Could not connect to Sentry. Check your auth token and organization slug, then reconnect."++ @patch("products.warehouse_sources.backend.temporal.data_imports.sources.sentry.sentry.make_tracked_session")+ def test_validate_credentials_request_error_hides_exception_text(self, mock_session) -> None:+ mock_session.return_value.get.side_effect = RequestException("connection refused to https://sentry.io")++ valid, error = validate_credentials(auth_token="token", organization_slug="acme")++ assert not valid+ assert error == "Could not reach Sentry to validate your credentials. Check your connection, then try again."+def test_sentry_source_rejects_unknown_api_base_url_at_runtime(self) -> None:with pytest.raises(ValueError,