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(error-tracking): stop capturing handled embedding blip at interceptor (#86759)

posthog[bot]f72e32dbd29e
diff --git a/posthog/temporal/common/posthog_client.py b/posthog/temporal/common/posthog_client.py
index 28e08680592c..56c92c001949 100644
--- a/posthog/temporal/common/posthog_client.py
+++ b/posthog/temporal/common/posthog_client.py
@@ -27,7 +27,13 @@ logger = get_write_only_logger()
# ApplicationError types that are expected control flow (e.g. activity-retry-as-poll
# probes, retryable transient-infra re-raises), not defects — same reasoning as the
# EgressBudgetExhausted exemption below.
-EXPECTED_CONTROL_FLOW_ERROR_TYPES = frozenset({"trace_not_settled", "TransientRepartitionError"})
+# "EmbeddingServiceUnavailable" is the literal string kept intentionally, not the product
+# constant EMBEDDING_SERVICE_UNAVAILABLE_ERROR_TYPE — this shared Temporal module must not
+# depend on a product. The error-tracking issue-created workflow fails open on it, so it is
+# expected control flow, not a defect.
+EXPECTED_CONTROL_FLOW_ERROR_TYPES = frozenset(
+ {"trace_not_settled", "TransientRepartitionError", "EmbeddingServiceUnavailable"}
+)
def _tag_team_id_on_current_span(input: ExecuteActivityInput | ExecuteWorkflowInput) -> None:
diff --git a/posthog/temporal/tests/common/test_error_tracking.py b/posthog/temporal/tests/common/test_error_tracking.py
index dae785e3564e..d254e15e4bf6 100644
--- a/posthog/temporal/tests/common/test_error_tracking.py
+++ b/posthog/temporal/tests/common/test_error_tracking.py
@@ -186,6 +186,27 @@ class NonReportableActivityWorkflow:
)
+async def expected_control_flow_activity(inputs: OptionallyFailingInputs) -> None:
+ # "EmbeddingServiceUnavailable" is a transport failure of the error-tracking embedding call
+ # that its workflow handles by failing open. The activity re-raises it and the interceptor,
+ # sitting outside the activity decorators, must not capture it a second time.
+ raise ApplicationError("embedding service unavailable", type="EmbeddingServiceUnavailable")
+
+
+class ExpectedControlFlowActivityWorkflow:
+ @workflow.run
+ async def run(self, inputs: OptionallyFailingInputs) -> None:
+ await workflow.execute_activity(
+ expected_control_flow_activity,
+ inputs,
+ start_to_close_timeout=dt.timedelta(minutes=1),
+ heartbeat_timeout=dt.timedelta(seconds=5),
+ retry_policy=RetryPolicy(maximum_attempts=1),
+ )
+
+
@workflow.defn
class DirectlyFailingWorkflow:
@workflow.run
@@ -415,6 +436,36 @@ async def test_non_reportable_error_is_not_captured(temporal_client: Client):
mock_ph_capture.assert_not_called()
+async def test_expected_control_flow_application_error_is_not_captured(temporal_client: Client):
+ """An ApplicationError whose type is in EXPECTED_CONTROL_FLOW_ERROR_TYPES (here the
+ error-tracking embedding transport failure) is expected control flow, not a defect. The
+ interceptor sits outside the activity decorators, so it must re-raise it without reporting it
+ to error tracking even when the activity already re-raised it uncaptured."""
+ task_queue = "TEST-TASK-QUEUE"
+ workflow_id = str(uuid.uuid4())
+
+ with patch("posthog.temporal.common.posthog_client.capture_exception") as mock_ph_capture:
+ async with Worker(
+ temporal_client,
+ task_queue=task_queue,
+ workflows=[ExpectedControlFlowActivityWorkflow],
+ activities=[expected_control_flow_activity],
+ interceptors=[PostHogClientInterceptor()],
+ workflow_runner=UnsandboxedWorkflowRunner(),
+ ):
+ with pytest.raises(WorkflowFailureError):
+ await temporal_client.execute_workflow(
+ "ExpectedControlFlowActivityWorkflow",
+ OptionallyFailingInputs(fail=True),
+ id=workflow_id,
+ task_queue=task_queue,
+ retry_policy=RetryPolicy(maximum_attempts=1),
+ )
+
+ mock_ph_capture.assert_not_called()
+
+
@pytest.mark.asyncio
async def test_workflow_only_error_is_captured(temporal_client: Client):
task_queue = "TEST-TASK-QUEUE"