: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(endpoints): keep hasMore when a run has no limit (#110334)
posthog[bot]8fa9f8274548
diff --git a/products/endpoints/backend/logic/execution.py b/products/endpoints/backend/logic/execution.pyindex 4930e84da2bb..2f4fa9d01673 100644--- a/products/endpoints/backend/logic/execution.py+++ b/products/endpoints/backend/logic/execution.py@@ -1093,7 +1093,8 @@ class EndpointExecutionService(PydanticModelMixin):if pagination and "results" in result:pagination.process_results(result)elif "results" in result:- result["hasMore"] = False+ # The query runner truncates unpaginated results at its default limit and sets hasMore itself.+ result["hasMore"] = bool(result.get("hasMore"))if "results" in result:result = {"results": result.pop("results"), **result}diff --git a/products/endpoints/backend/tests/test_endpoint_execution.py b/products/endpoints/backend/tests/test_endpoint_execution.pyindex 5047a1840f74..deb1f660c372 100644--- a/products/endpoints/backend/tests/test_endpoint_execution.py+++ b/products/endpoints/backend/tests/test_endpoint_execution.py@@ -1714,6 +1714,30 @@ class TestEndpointExecution(ClickhouseTestMixin, APIBaseTest):assert pagination.limit == req_limitassert pagination.offset == req_offset+ @parameterized.expand(+ [+ ("truncated_at_default_limit", 150, 100, True),+ ("under_default_limit", 20, 20, False),+ ]+ )+ def test_inline_run_without_limit_reports_has_more(self, _name, num_rows, expected_rows, expected_has_more):+ endpoint = create_endpoint_with_version(+ name="no_limit_has_more",+ team=self.team,+ query={"kind": "HogQLQuery", "query": f"SELECT number FROM numbers({num_rows})"},+ created_by=self.user,+ is_active=True,+ )++ response = self.client.post(+ f"/api/environments/{self.team.id}/endpoints/{endpoint.name}/run/", {}, format="json"+ )++ self.assertEqual(response.status_code, status.HTTP_200_OK, response.content)+ data = response.json()+ self.assertEqual(len(data["results"]), expected_rows)+ self.assertEqual(data["hasMore"], expected_has_more)+def test_inline_pagination_with_variables(self):"""Pagination on a HogQL query with {variables.*} placeholders must not raise."""query_sql = "SELECT event, count() FROM events WHERE event = {variables.event_name} GROUP BY event LIMIT 1000"