: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(warehouse-sources): unwrap the kickscale response envelope (#107769)
posthog[bot]654bf46041d5
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/kickscale/kickscale.py b/products/warehouse_sources/backend/temporal/data_imports/sources/kickscale/kickscale.pyindex dafbdab1b11c..90678373383d 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/kickscale/kickscale.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/kickscale/kickscale.py@@ -58,8 +58,12 @@ class KickscaleAuth(AuthConfigBase):class KickscalePageNumberPaginator(PageNumberPaginator):- """Kickscale's list responses carry no total-count field, so a full-strength page is the- only signal there's more to fetch; a short (or empty) page ends the sync."""+ """A full page of `data` is the signal that there is more to fetch; a short (or empty) page+ ends the sync.++ The envelope also carries `meta.total`, but a short-page check needs no second parse of a+ body that can hold 100 full transcripts.+ """def __init__(self, page_size: int) -> None:super().__init__(base_page=0, page_param="page")@@ -114,6 +118,10 @@ def get_resource(endpoint_config: Endpoint = {"path": config.path,+ # Rows arrive in a `{"data": [...], "meta": {...}}` envelope. Without the selector the+ # whole envelope becomes one row, and the paginator sees a short page and stops.+ "data_selector": "data",+ "data_selector_required": True,"params": {"pageSize": DEFAULT_PAGE_SIZE,"sortingOrder": "ascending",diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/kickscale/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/kickscale/settings.pyindex 2695938e3cfb..f72d6ead5a24 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/kickscale/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/kickscale/settings.py@@ -8,9 +8,8 @@ from products.warehouse_sources.backend.types import IncrementalField# The OpenAPI document declares no `servers` entry, so the base URL is hardcoded.KICKSCALE_BASE_URL = "https://api.kickscale.com"-# Kickscale documents a 20-row default page size with a maximum recommended 100. Responses are a-# bare JSON array with no total-count field, so pagination stops once a page returns fewer than-# this many rows.+# Kickscale documents a 20-row default page size with a maximum recommended 100. Pagination stops+# once the `data` list of a page holds fewer than this many rows.DEFAULT_PAGE_SIZE = 100# Comments, ratings, CRM links and re-analysis can land on a meeting/call after its `date`, anddiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/kickscale/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/kickscale/source.pyindex 71e46a0fe177..921ef5ade3aa 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/kickscale/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/kickscale/source.py@@ -47,8 +47,11 @@ class KickscaleSource(ResumableSource[KickscaleSourceConfig, KickscaleResumeConfdef get_non_retryable_errors(self) -> dict[str, str | None]:return {- "403 Client Error: Forbidden for url": "Kickscale rejected the API key and client ID. "- "Check both values under Settings > Integrations > API & Webhooks and reconnect.",+ # Kickscale can refuse one endpoint while the same key reads another, so a 403 does not+ # always mean the credentials are wrong.+ "403 Client Error: Forbidden for url": "Kickscale denied access to this table. Check that "+ "the API key and client ID under Settings > Integrations > API & Webhooks are correct and "+ "that your Kickscale workspace has access to this data, then reconnect.",}def get_canonical_descriptions(self) -> CanonicalDescriptions:diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/kickscale/tests/test_kickscale.py b/products/warehouse_sources/backend/temporal/data_imports/sources/kickscale/tests/test_kickscale.pyindex 2f75b6f95127..cd377f1d945f 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/kickscale/tests/test_kickscale.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/kickscale/tests/test_kickscale.py@@ -150,9 +150,10 @@ def test_validate_credentials_status_mapping(assert mock_session.call_args.kwargs["allow_redirects"] is False-def _make_http_response(body: list[dict[str, Any]], status_code: int = 200) -> Response:+def _make_http_response(rows: list[dict[str, Any]], status_code: int = 200) -> Response:resp = Response()resp.status_code = status_code+ body = {"data": rows, "meta": {"total": 101, "returned": len(rows), "page": 0, "pageSize": 100}}resp._content = json.dumps(body).encode()resp.headers["Content-Type"] = "application/json"return resp@@ -163,7 +164,7 @@ class TestKickscaleSourceResumeBehavior:def _drive(self, endpoint: str, manager: MagicMock, responses: list[Response]- ) -> tuple[MagicMock, list[dict[str, Any]]]:+ ) -> tuple[list[dict[str, Any]], list[dict[str, Any]]]:sent_params: list[dict[str, Any]] = []response_iter = iter(responses)@@ -187,8 +188,8 @@ class TestKickscaleSourceResumeBehavior:job_id="test_job",resumable_source_manager=manager,)- list(cast(Iterable[Any], response.items()))- return mock_session, sent_params+ rows = [row for page in cast(Iterable[Any], response.items()) for row in page]+ return rows, sent_params@pytest.mark.parametrize("endpoint", ["meetings", "calls"])def test_fresh_run_pages_until_short_page(self, endpoint: str) -> None:@@ -199,14 +200,24 @@ class TestKickscaleSourceResumeBehavior:_make_http_response([{"id": f"m{i}"} for i in range(100)]),_make_http_response([{"id": "m100"}]),]- _, sent_params = self._drive(endpoint, manager, responses)+ rows, sent_params = self._drive(endpoint, manager, responses)pages_sent = [p.get("page") for p in sent_params]assert pages_sent == [0, 1]+ assert [row["id"] for row in rows] == [f"m{i}" for i in range(101)]saved = [call.args[0] for call in manager.save_state.call_args_list]assert saved == [KickscaleResumeConfig(page=1)]+ def test_empty_page_yields_no_rows(self) -> None:+ manager = MagicMock(spec=ResumableSourceManager)+ manager.can_resume.return_value = False++ rows, sent_params = self._drive("calls", manager, [_make_http_response([])])++ assert rows == []+ assert [p.get("page") for p in sent_params] == [0]+def test_resume_seeds_paginator_with_saved_page(self) -> None:manager = MagicMock(spec=ResumableSourceManager)manager.can_resume.return_value = True