: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): stop reporting integration-service blips during schema discovery (#97991)
Tom Owersdd0af5474da3
diff --git a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/sync_new_schemas.py b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/sync_new_schemas.pyindex af4c68ed8917..3af482e0628b 100644--- a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/sync_new_schemas.py+++ b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/sync_new_schemas.py@@ -6,6 +6,8 @@ from django.db import close_old_connectionsfrom structlog.contextvars import bind_contextvarsfrom temporalio import activity+from posthog.exceptions_capture import capture_exception+from posthog.integration_secrets.errors import IntegrationSecretsFailurefrom posthog.models.integration import UndecryptedIntegrationSecretErrorfrom posthog.temporal.common.errors import NonReportableErrorfrom posthog.temporal.common.logger import get_logger@@ -97,7 +99,24 @@ def sync_new_schemas_activity(inputs: SyncNewSchemasActivityInputs) -> None:if isinstance(e, UndecryptedIntegrationSecretError):logger.warning(f"Skipping schema discovery due to non-retryable source error: {e}")return+error_msg = str(e)+ # Every credential the integration service holds is PostHog's own (OAuth app secrets,+ # API keys), never the customer's, and none of its failure states are permanent — a+ # burned key gets re-provisioned, an unreachable service comes back. Unlike the skips+ # above, this isn't ours to give up on: re-raise wrapped in NonReportableError so the+ # workflow's own retry policy (discover_schemas_workflow.py) retries the activity, the+ # same recovery import_data_sync.py's _handle_import_error already gives the per-schema+ # sync path, without minting an error tracking issue per credential read for a platform+ # blip the service's own availability alerting already covers.+ if isinstance(e, IntegrationSecretsFailure):+ if e.reportable:+ capture_exception(e)+ logger.exception(error_msg)+ else:+ logger.warning(error_msg)+ raise NonReportableError(error_msg) from e+# PostHog's own egress proxy throttled or refused the connection. Raise rather than# skip so Temporal still retries this discovery run, and classify here rather than per# source so every connector gets the same treatment.diff --git a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_sync_new_schemas.py b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_sync_new_schemas.pyindex b10590d3c8b9..db0427aaf007 100644--- a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_sync_new_schemas.py+++ b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_sync_new_schemas.py@@ -5,6 +5,7 @@ from unittest import mockfrom django.db import OperationalError+from posthog.integration_secrets.errors import IntegrationServiceUnreachableError, SecretMissingErrorfrom posthog.models.integration import UndecryptedIntegrationSecretErrorfrom posthog.temporal.common.errors import NonReportableError@@ -162,6 +163,32 @@ def test_undecrypted_integration_secret_error_is_skipped():_run_activity(source_mock)+ "error,expect_capture",+ [+ (IntegrationServiceUnreachableError("connect timeout"), False),+ (SecretMissingError("some_key"), True),+ ],+ ids=["non_reportable_service_unreachable", "reportable_secret_missing"],+)+def test_integration_secrets_failure_is_retried_and_reported_by_reportable(error, expect_capture):+ # An integration-service failure is never the customer's fault, so discovery must not disable+ # the source (would need `handle_non_retryable_error`) — it must re-raise as NonReportableError+ # so the workflow's retry policy picks it back up. `reportable` alone decides whether a person+ # hears about it: capturing an unreachable service opens an issue per credential read for what+ # its own availability alerting already covers. Assert the capture, because asserting the raise+ # alone passes even when everything is captured.+ source_mock = mock.MagicMock()+ source_mock.parse_config.return_value = {}+ source_mock.get_schemas.side_effect = error+ source_mock.get_non_retryable_errors.return_value = {}++ with mock.patch.object(module, "capture_exception") as capture, pytest.raises(NonReportableError):+ _run_activity(source_mock)++ assert capture.called is expect_capture++def test_discovery_uses_source_pinned_api_version():# A pinned source must discover schemas under its pin, not the default — dropping the pin# here makes discovery reconcile under the wrong vendor version (tables vanish/duplicate).