: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(hex): stop retrying GetProjectRuns' 422 Unprocessable Entity (#122476)
Tom Owers06654ea16cb0
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/hex/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/hex/source.pyindex 8ab64d09846b..3608fc8bf7ef 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/hex/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/hex/source.py@@ -91,6 +91,11 @@ If your workspace runs on a single-tenant or self-hosted Hex deployment, enter i"401 Client Error": "Invalid Hex API token. Please generate a new token in your Hex workspace settings and reconnect.","403 Client Error": "Your Hex API token lacks the required permissions. Please check the token's access and try again.",HOST_NOT_ALLOWED_ERROR: "The Hex workspace URL is not allowed. Please use your workspace's Hex URL.",+ # Hex's structured error code for a semantically-rejected request (seen on GetProjectRuns+ # for a specific project, e.g. one in a state its run history can't be queried in).+ # Matched on the stable error code rather than the per-request URL; every retry sends the+ # identical request and fails identically, so there's nothing to gain from retrying.+ "code=UNPROCESSABLE_CONTENT": "Hex rejected a request as unprocessable. This is usually caused by the state of a specific project in your Hex workspace rather than something PostHog can retry. Check the project in Hex, or contact Hex support if this persists.",}def get_canonical_descriptions(self) -> CanonicalDescriptions:diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/hex/tests/test_hex.py b/products/warehouse_sources/backend/temporal/data_imports/sources/hex/tests/test_hex.pyindex e3ece8d48800..19fa6094dadd 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/hex/tests/test_hex.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/hex/tests/test_hex.py@@ -2,6 +2,7 @@ from typing import Anyfrom unittest import mock+from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import error_message_matchesfrom products.warehouse_sources.backend.temporal.data_imports.sources.common.testing import (ScriptedResponse,SourceDriver,@@ -118,6 +119,18 @@ class TestProjectRunsFanout:assert [row["runId"] for row in result.rows] == ["r-b"]assert result.paths == ["/api/v1/projects", "/api/v1/projects/p2/runs"]+ def test_422_on_project_runs_is_classified_non_retryable(self) -> None:+ # Hex rejects GetProjectRuns for a specific project with a 422 and a structured error+ # code. Every retry sends the identical request and fails identically, so the raised+ # error must match a `get_non_retryable_errors()` key, not just reach the caller.+ result = _driver().run(+ "project_runs",+ [_projects_page(["p1"]), ScriptedResponse(status=422, json={"code": "UNPROCESSABLE_CONTENT"})],+ )++ assert result.raised is not None+ assert error_message_matches(str(result.raised), HexSource().get_non_retryable_errors())+class TestPerProjectCursorFanout:def test_queried_tables_follow_child_cursor_and_carry_project_id(self) -> None: