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(gitlab): stop reporting exhausted transient retries as errors (#87629)

Tom Owerse35b87a12646
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/gitlab/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/gitlab/source.py
index f03445115baa..f4e9218e0d2e 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/gitlab/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/gitlab/source.py
@@ -109,6 +109,13 @@ For self-managed GitLab, set the instance URL (for example `https://gitlab.examp
HTTP_NOT_ALLOWED_ERROR: "The GitLab host must use HTTPS. Please update the instance URL to use https://.",
}
+ def get_retryable_errors(self) -> set[str]:
+ # A GitLabRetryableError (rate limit or transient upstream 5xx) that survives
+ # fetch_page's own tenacity retry still gets picked up by Temporal's activity retry;
+ # classify it as retryable so it's logged as a warning rather than tracked as an
+ # exception. Mirrors GitHub's equivalent case.
+ return {"GitLab API error (retryable)"}
+
def get_schemas(
self,
config: GitLabSourceConfig,
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/gitlab/tests/test_gitlab_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/gitlab/tests/test_gitlab_source.py
index d9b9c66d17bf..84e26984e323 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/gitlab/tests/test_gitlab_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/gitlab/tests/test_gitlab_source.py
@@ -3,6 +3,7 @@ from unittest import mock
from posthog.schema import ReleaseStatus, SourceFieldInputConfig, SourceFieldInputConfigType
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import error_message_matches
from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManager
from products.warehouse_sources.backend.temporal.data_imports.sources.gitlab.gitlab import GitLabResumeConfig
from products.warehouse_sources.backend.temporal.data_imports.sources.gitlab.settings import ENDPOINTS
@@ -56,6 +57,15 @@ class TestGitLabSource:
def test_non_retryable_errors(self, expected_key):
assert expected_key in self.source.get_non_retryable_errors()
+ def test_transient_5xx_error_is_retryable_not_non_retryable(self):
+ # A GitLabRetryableError (any transient upstream 5xx) that exhausts fetch_page's tenacity
+ # retry must stay retryable, so a GitLab-side outage doesn't disable the source.
+ observed_error = "GitLab API error (retryable): status=502, url=https://gitlab.com/api/v4/projects/1/issues"
+ non_retryable_errors = self.source.get_non_retryable_errors()
+ assert not any(key in observed_error for key in non_retryable_errors)
+ retryable_errors = self.source.get_retryable_errors()
+ assert error_message_matches(observed_error, retryable_errors)
+
def test_get_schemas_returns_all_endpoints(self):
schemas = self.source.get_schemas(self.config, self.team_id)
assert {s.name for s in schemas} == set(ENDPOINTS)