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(replay-vision): classify transient rasterizer failures as retryable (#92756)

posthog[bot]963ec7d98459
diff --git a/products/replay_vision/backend/temporal/workflow.py b/products/replay_vision/backend/temporal/workflow.py
index 7e8275e7b72a..e807b2093afc 100644
--- a/products/replay_vision/backend/temporal/workflow.py
+++ b/products/replay_vision/backend/temporal/workflow.py
@@ -172,6 +172,14 @@ _RASTERIZER_NO_SNAPSHOTS_TYPE = "NO_SNAPSHOTS"
# walking the pod into its memory limit. That size is a fixed property of the recording, so no retry helps.
_RASTERIZER_TOO_LARGE_TYPE = "RECORDING_TOO_LARGE"
+# Rasterizer codes that mean a PostHog-side dependency the renderer talks to was unreachable or slow — the
+# recording-api it fetches the block listing and data from, or the object storage it uploads the video to — not
+# that the recording itself can't render. They belong in the same transient bucket as an activity timeout against
+# those dependencies (see `_activity_timeout_kind`), so the user gets a retry prompt, not a "known issue" label.
+_RASTERIZER_INFRA_TRANSIENT_TYPES = frozenset(
+ {"BLOCK_LISTING_FAILED", "DATA_LOAD_FAILED", "S3_UPLOAD_FAILED", "S3_UPLOAD_UNDECODABLE_RESPONSE"}
+)
+
def _activity_timeout_kind(e: BaseException) -> str | None:
"""Map an activity start-to-close/heartbeat timeout onto whichever side ran out of time."""
@@ -190,6 +198,12 @@ def _failure_type(e: BaseException) -> str | None:
return getattr(cause, "type", None)
+def _failure_non_retryable(e: BaseException) -> bool:
+ """Whether the leaf ApplicationError was flagged non-retryable, surviving the same wrapping."""
+ cause = unwrap_temporal_cause(e) or e
+ return bool(getattr(cause, "non_retryable", False))
+
+
def _extract_kind_for_type(e: BaseException, expected_type: str) -> str | None:
"""Pull a kind string off a kinded ApplicationError, surviving Temporal's ActivityError wrap."""
if _failure_type(e) != expected_type:
@@ -206,6 +220,16 @@ def _root_cause_message(e: BaseException) -> str:
return truncate_for_temporal_payload(msg, MAX_ERROR_MESSAGE_CHARS)
+def _normalized_rasterizer_infra_message(code: str) -> str:
+ """A stable message for a transient rasterizer dependency failure, keyed on the code alone.
+
+ The raw text carries the errno, the pod address and the pooler wording, all of which vary per
+ occurrence, so copying it verbatim mints a fresh error-tracking issue for one root cause. Keying
+ the message on the code collapses those variants back into a single issue.
+ """
+ return f"rasterizer could not reach a PostHog dependency ({code})"
+
+
def _encode_reason(kind: str, message: str) -> str:
"""`kind:message` — the frontend splits on the first colon to render the kind as a badge."""
return f"{kind}:{message}"
@@ -437,6 +461,27 @@ class ApplyScannerWorkflow(PostHogWorkflow):
):
# Gate as ineligible, not failed, so the user reads "too large" instead of a "known issue" retry prompt.
raise IneligibleSessionError(_root_cause_message(e), kind=IneligibleSessionKind.TOO_LARGE) from e
+ rasterizer_type = _failure_type(e)
+ # The rasterizer flags a genuine transport blip (5xx, timeout, dropped connection) as retryable
+ # but a permanent 4xx or a malformed listing as non-retryable. Only the retryable ones are the
+ # "dependency was slow" story; a non-retryable leaf keeps the RASTERIZATION_FAILED path below, so
+ # it gets neither a false retry prompt nor a message that merges it into the transient-outage issue.
+ if rasterizer_type in _RASTERIZER_INFRA_TRANSIENT_TYPES and not _failure_non_retryable(e):
+ # A PostHog dependency blip, not a broken recording. Classify transient so the observation
+ # stays retryable, and keep the raw errno and pod address in the worker log only: `from None`
+ # drops the volatile cause so error tracking groups the outage by the stable message alone
+ # instead of minting a fresh issue per errno and pod address.
+ # Interpolate the code and detail into the message text, not `extra={...}`: the worker's
+ # stdlib formatter chain has no `ExtraAdder`, so record attributes never reach the rendered
+ # line, and the promised on-call copy would carry neither field.
+ wf.logger.warning(
+ "replay_vision.rasterizer_infra_transient code=%s detail=%s",
+ rasterizer_type,
+ _root_cause_message(e),
+ )
+ raise ScannerFailureError(
+ _normalized_rasterizer_infra_message(rasterizer_type), kind=FailureKind.INFRA_TRANSIENT
+ ) from None
# Direct cause only: a nested activity timeout inside the child already bumped the
# counter there, and matching it here would double-count one run.
if (
diff --git a/products/replay_vision/backend/tests/test_temporal.py b/products/replay_vision/backend/tests/test_temporal.py
index 2c338a824c88..b2ad08c04393 100644
--- a/products/replay_vision/backend/tests/test_temporal.py
+++ b/products/replay_vision/backend/tests/test_temporal.py
@@ -17,6 +17,7 @@ import psycopg.errors
from asgiref.sync import sync_to_async
from google.genai.errors import APIError
from parameterized import parameterized
+from posthoganalytics.exception_utils import exceptions_from_error_tuple
from prometheus_client import REGISTRY
from structlog.testing import capture_logs
from temporalio.exceptions import (
@@ -2353,6 +2354,68 @@ async def test_apply_scanner_workflow_splits_rasterizer_failures_by_cause(
assert upload_video_to_gemini_activity not in called
+ "leaf_message,non_retryable,expected_kind,expected_reason",
+ [
+ # A genuine transport blip (5xx, timeout, dropped connection) reaches the parent as a retryable
+ # BLOCK_LISTING_FAILED whose message carries the errno and pod address. It must land as retryable
+ # infra_transient with the errno and address dropped, so one outage can't mint a fresh error-tracking
+ # issue per variant.
+ (
+ "Failed to fetch block listing: connect ECONNREFUSED 10.0.0.5:6738",
+ False,
+ FailureKind.INFRA_TRANSIENT,
+ "infra_transient:rasterizer could not reach a PostHog dependency (BLOCK_LISTING_FAILED)",
+ ),
+ # A permanent 4xx (auth, bad request) or malformed listing reaches the parent as a non-retryable
+ # BLOCK_LISTING_FAILED. Retrying can't heal it, so it must keep the recording-level rasterization_failed
+ # label with its own message, not a false retry prompt that merges into the transient-outage issue.
+ (
+ "Failed to fetch block listing: 401 - unauthorized",
+ True,
+ FailureKind.RASTERIZATION_FAILED,
+ "rasterization_failed:Failed to fetch block listing: 401 - unauthorized",
+ ),
+ ],
+)
+async def test_apply_scanner_workflow_classifies_rasterizer_dependency_failure_by_retryability(
+ leaf_message: str, non_retryable: bool, expected_kind: FailureKind, expected_reason: str
+) -> None:
+ new_observation_id = uuid.uuid4()
+ leaf = ApplicationError(leaf_message, type="BLOCK_LISTING_FAILED", non_retryable=non_retryable)
+ mocks = _WorkflowMocks(
+ activity_results={
+ create_observation_activity: CreateObservationOutput(
+ observation_id=new_observation_id, was_created=True, scanner_type=ScannerType.MONITOR
+ ),
+ ensure_session_asset_activity: EnsureSessionAssetOutput(asset_id=42),
+ },
+ child_error=_wrap_in_child_workflow_error(_wrap_in_activity_error(leaf)),
+ )
+
+ with pytest.raises(ScannerFailureError) as exc_info:
+ await _run_workflow(_build_inputs(session_id="sess-blocklist"), mocks)
+
+ assert exc_info.value.kind is expected_kind
+ called = {fn for fn, _ in mocks.activity_calls}
+ assert mark_observation_failed_activity in called
+ assert mark_observation_ineligible_activity not in called
+ assert mocks.activity_calls[-1][1].error_reason == expected_reason
+
+ if expected_kind is FailureKind.INFRA_TRANSIENT:
+ # `from None` keeps the volatile cause out of the chain error tracking serializes, so the outage
+ # groups by the stable message instead of the errno and pod address the leaf still carries.
+ assert exc_info.value.__cause__ is None
+ assert exc_info.value.__suppress_context__ is True
+ # Prove it through the real capture serializer: the errno and pod address must not survive into
+ # `$exception_list`, or one outage still fragments into a fresh error-tracking issue per variant.
+ serialized = exceptions_from_error_tuple((type(exc_info.value), exc_info.value, exc_info.value.__traceback__))
+ captured = " ".join(str(item.get("value")) for item in serialized)
+ assert "ECONNREFUSED" not in captured
+ assert "10.0.0.5" not in captured
+
+
@pytest.mark.asyncio
async def test_apply_scanner_workflow_cleans_up_gemini_file_when_call_provider_fails() -> None:
new_observation_id = uuid.uuid4()
diff --git a/products/replay_vision/frontend/replay_scanners/types.ts b/products/replay_vision/frontend/replay_scanners/types.ts
index 8ce34a8aa401..ac375aa6aa6a 100644
--- a/products/replay_vision/frontend/replay_scanners/types.ts
+++ b/products/replay_vision/frontend/replay_scanners/types.ts
@@ -139,8 +139,9 @@ const FAILURE_KINDS: Record<FailureKind, FailureKindInfo> = {
retryHint: "A retry runs the scanner's current prompt. Edit the prompt first if you haven't changed it yet.",
},
infra_transient: {
- label: 'PostHog timed out',
- description: 'A PostHog service took too long while preparing this recording. Retry the scan in a few minutes.',
+ label: 'PostHog service unavailable',
+ description:
+ 'A PostHog service was slow or unavailable while preparing this recording. Retry the scan in a few minutes.',
retryWorthwhile: true,
},
internal_error: {