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(linear): treat deleted integration as non-retryable (#63666)

Tom Owers5089b3a8312a
diff --git a/posthog/temporal/data_imports/sources/linear/source.py b/posthog/temporal/data_imports/sources/linear/source.py
index 0dd3d700ea2b..af17c79baead 100644
--- a/posthog/temporal/data_imports/sources/linear/source.py
+++ b/posthog/temporal/data_imports/sources/linear/source.py
@@ -57,6 +57,10 @@ class LinearSource(ResumableSource[LinearSourceConfig, LinearResumeConfig], OAut
return {
"401 Client Error": "Invalid Linear credentials. Please reconnect your account.",
"403 Client Error": "Access forbidden. Your token may lack required permissions.",
+ # The linked OAuth integration was deleted while the source still references it.
+ # Retrying can never resolve this — the integration won't reappear — so stop and
+ # ask the user to reconnect. Matched as a substring; the trailing integration id varies.
+ "Integration not found": "The linked Linear integration no longer exists. Please reconnect your Linear account.",
}
def _get_access_token(self, config: LinearSourceConfig, team_id: int) -> str:
diff --git a/posthog/temporal/data_imports/sources/linear/test_linear.py b/posthog/temporal/data_imports/sources/linear/test_linear.py
index e533aee5112f..29342d89a233 100644
--- a/posthog/temporal/data_imports/sources/linear/test_linear.py
+++ b/posthog/temporal/data_imports/sources/linear/test_linear.py
@@ -13,6 +13,7 @@ from posthog.temporal.data_imports.sources.linear.linear import (
_make_paginated_request,
linear_source,
)
+from posthog.temporal.data_imports.sources.linear.source import LinearSource
def _make_response(nodes: list[dict[str, Any]], has_next_page: bool, end_cursor: str | None) -> MagicMock:
@@ -252,3 +253,30 @@ class TestLinearSource:
assert pages == [[{"id": "a"}], [{"id": "b"}]]
manager.save_state.assert_called_once_with(LinearResumeConfig(cursor="cursor-a"))
+
+
+class TestLinearSourceNonRetryableErrors:
+ @parameterized.expand(
+ [
+ # The OAuthMixin raises "Integration not found: <id>" when the linked integration was
+ # deleted. The id varies, so matching must rely on the stable prefix.
+ ("deleted_integration", "Integration not found: 165665"),
+ ("auth_401", "401 Client Error: Unauthorized for url: https://api.linear.app/graphql"),
+ ("forbidden_403", "403 Client Error: Forbidden for url: https://api.linear.app/graphql"),
+ ]
+ )
+ def test_non_retryable_errors_match(self, _name: str, observed_error: str) -> None:
+ non_retryable_errors = LinearSource().get_non_retryable_errors()
+ assert any(key in observed_error for key in non_retryable_errors)
+
+ @parameterized.expand(
+ [
+ ("transient_500", "500 Server Error for url: https://api.linear.app/graphql"),
+ ("rate_limited", "Linear: rate limited (429)"),
+ ("graphql_error", "Linear GraphQL error: Something failed"),
+ ]
+ )
+ def test_non_retryable_errors_does_not_match_transient(self, _name: str, observed_error: str) -> None:
+ non_retryable_errors = LinearSource().get_non_retryable_errors()
+ # Transient/server errors must stay retryable so the pipeline backs off and retries.
+ assert not any(key in observed_error for key in non_retryable_errors)