: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(integrations): order the integration list so pagination keeps every row (#101498)
posthog[bot]fd1bf63862d3
diff --git a/posthog/api/integration.py b/posthog/api/integration.pyindex 42a322e3be2d..fee2eb977e8c 100644--- a/posthog/api/integration.py+++ b/posthog/api/integration.py@@ -1280,7 +1280,11 @@ class IntegrationViewSet("request_access",]permission_classes = [IntegrationManagementPermission]- queryset = defer_repository_cache_fields(Integration.objects.all())+ # LimitOffsetPagination needs a total order, or Postgres can return a row on neither side of a+ # page boundary. Clients page this list to find one kind, so a dropped row reads as+ # "not configured". Order oldest-first: several clients take the first row of a kind as their+ # default connection.+ queryset = defer_repository_cache_fields(Integration.objects.all()).order_by("created_at", "id")serializer_class = IntegrationSerializerfilter_backends = [DjangoFilterBackend]filterset_fields = ["kind"]diff --git a/posthog/api/test/test_integration.py b/posthog/api/test/test_integration.pyindex 92170d525527..24117fbd0d3e 100644--- a/posthog/api/test/test_integration.py+++ b/posthog/api/test/test_integration.py@@ -2577,6 +2577,22 @@ class TestIntegrationAPIKeyAccess:assert len(results) == 1assert results[0]["kind"] == "twilio"+ def test_paginated_list_covers_every_integration_once(self, client: HttpClient):+ client.force_login(self.user)+ now = timezone.now()+ # Write the rows in the reverse of the order the endpoint must return, so a page that trusts+ # the physical row order fails this.+ Integration.objects.filter(pk=self.github_integration.pk).update(created_at=now)+ Integration.objects.filter(pk=self.twilio_integration.pk).update(created_at=now - timedelta(minutes=1))++ paged_ids = []+ for offset in [0, 1]:+ response = client.get(f"/api/environments/{self.team.pk}/integrations/?limit=1&offset={offset}")+ assert response.status_code == status.HTTP_200_OK+ paged_ids += [result["id"] for result in response.json()["results"]]++ assert paged_ids == [self.twilio_integration.id, self.github_integration.id]+class TestGithubAccountTypeHelper:@parameterized.expand(