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(vitally): treat auth failures as non-retryable (#63721)

Tom Owers47e2cdb55d24
diff --git a/posthog/temporal/data_imports/sources/vitally/source.py b/posthog/temporal/data_imports/sources/vitally/source.py
index a167dededaf7..4d2e59557a84 100644
--- a/posthog/temporal/data_imports/sources/vitally/source.py
+++ b/posthog/temporal/data_imports/sources/vitally/source.py
@@ -104,6 +104,14 @@ class VitallySource(SimpleSource[VitallySourceConfig]):
return False, "Invalid credentials"
+ def get_non_retryable_errors(self) -> dict[str, str | None]:
+ # The Vitally host is per-customer on US (`<subdomain>.rest.vitally.io`), so match on the
+ # stable status text rather than a fixed URL prefix.
+ return {
+ "401 Client Error: Unauthorized for url": "Your Vitally secret token is invalid or has been revoked. Please check your token and reconnect.",
+ "403 Client Error: Forbidden for url": "Your Vitally secret token does not have permission to access this data. Please check the token's permissions and reconnect.",
+ }
+
def source_for_pipeline(self, config: VitallySourceConfig, inputs: SourceInputs) -> SourceResponse:
items = vitally_source(
secret_token=config.secret_token,
diff --git a/posthog/temporal/data_imports/sources/vitally/tests/test_vitally.py b/posthog/temporal/data_imports/sources/vitally/tests/test_vitally.py
index 84198cb13221..3ba5a9ac47ce 100644
--- a/posthog/temporal/data_imports/sources/vitally/tests/test_vitally.py
+++ b/posthog/temporal/data_imports/sources/vitally/tests/test_vitally.py
@@ -268,3 +268,30 @@ class TestVitallySourceGetSchemas:
names = {s.name for s in schemas}
assert {"Accounts", "Conversations", "Custom_Objects", "Messages"} <= names
assert not any(s.name.startswith(CUSTOM_OBJECT_SCHEMA_PREFIX) for s in schemas)
+
+
+class TestVitallyNonRetryableErrors:
+ @pytest.mark.parametrize(
+ "observed_error",
+ [
+ # US uses a per-customer subdomain, EU a fixed host — both must be recognised.
+ "401 Client Error: Unauthorized for url: https://acme.rest.vitally.io/resources/conversations?limit=100",
+ "403 Client Error: Forbidden for url: https://acme.rest.vitally.io/resources/organizations?limit=100",
+ "401 Client Error: Unauthorized for url: https://rest.vitally-eu.io/resources/users?limit=1",
+ ],
+ )
+ def test_auth_failures_are_non_retryable(self, observed_error):
+ non_retryable_errors = VitallySource().get_non_retryable_errors()
+ assert any(key in observed_error for key in non_retryable_errors)
+
+ @pytest.mark.parametrize(
+ "other_error",
+ [
+ "500 Server Error for url: https://acme.rest.vitally.io/resources/conversations",
+ "429 Client Error: Too Many Requests for url: https://acme.rest.vitally.io/resources/accounts",
+ "Connection aborted: read timeout",
+ ],
+ )
+ def test_transient_errors_remain_retryable(self, other_error):
+ non_retryable_errors = VitallySource().get_non_retryable_errors()
+ assert not any(key in other_error for key in non_retryable_errors)