: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
feat(warehouse): add kong konnect control plane and core entity tables (#113345)
Tom Owers6408fb7cd637
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.mdindex 83a81706893c..f2d07c6ac32b 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md@@ -4837,10 +4837,10 @@ Today (1): `api_requests`Diffed against: <https://raw.githubusercontent.com/Kong/developer.konghq.com/main/api-specs/konnect/analytics-requests/v2/openapi.yaml>-- [ ] `/control-planes (Control Planes API v2)` — lookup that resolves the control_plane_id dimension carried on every api_requests row (high)-- [ ] `/control-planes/{id}/core-entities/services` — lookup resolving the service_id on api_requests to a named gateway service (high)-- [ ] `/control-planes/{id}/core-entities/routes` — lookup resolving route_id on api_requests to a path/method (high)-- [ ] `/control-planes/{id}/core-entities/consumers` — lookup resolving consumer_id on api_requests to a named API consumer (high)+- [x] `/control-planes (Control Planes API v2)` — lookup that resolves the control_plane_id dimension carried on every api_requests row (high)+- [x] `/control-planes/{id}/core-entities/services` — lookup resolving the service_id on api_requests to a named gateway service (high)+- [x] `/control-planes/{id}/core-entities/routes` — lookup resolving route_id on api_requests to a path/method (high)+- [x] `/control-planes/{id}/core-entities/consumers` — lookup resolving consumer_id on api_requests to a named API consumer (high)- [ ] `/api-products (API Products v2)` — lookup for the api_product / api_product_version dimensions filterable on api_requests (high)- [ ] `/metrics (Analytics Metrics v2)` — vendor's aggregated traffic, latency and error-rate metrics without re-aggregating raw request rows (medium)- [ ] `/control-planes/{id}/core-entities/plugins` — which rate-limit/auth plugins were active on a service or route when traffic was served (medium)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/kong_konnect/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/kong_konnect/canonical_descriptions.pyindex dbe0f1731520..375a5d66e140 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/kong_konnect/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/kong_konnect/canonical_descriptions.py@@ -51,4 +51,73 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"mcp_info": "Model Context Protocol call details for AI routes (nullable), including session id and per-tool call method, latency, and error.",},},+ "control_planes": {+ "description": "Control planes in the Konnect organization. Joins to api_requests on control_plane.",+ "docs_url": "https://developer.konghq.com/api/konnect/control-planes/v2/",+ "columns": {+ "id": "The control plane ID.",+ "name": "The name of the control plane.",+ "description": "The description of the control plane in Konnect.",+ "labels": "Key/value labels attached to the control plane.",+ "config": "Control plane configuration, including cluster type, auth type, and control plane and telemetry endpoints.",+ "created_at": "Timestamp of when the control plane was created.",+ "updated_at": "Timestamp of when the control plane was last updated.",+ },+ },+ "services": {+ "description": "Gateway services, one row per service per control plane. Joins to api_requests on control_plane_id and gateway_service.",+ "docs_url": "https://developer.konghq.com/api/konnect/control-planes-config/v2/",+ "columns": {+ "control_plane_id": "ID of the control plane the service belongs to. Service IDs are unique only within a control plane.",+ "id": "Unique identifier of the service within its control plane.",+ "name": "The service name.",+ "host": "The host of the upstream server.",+ "port": "The upstream server port.",+ "protocol": "The protocol used to communicate with the upstream.",+ "path": "The path used in requests to the upstream server.",+ "enabled": "Whether the service is active. Routes attached to a disabled service behave as if they do not exist.",+ "retries": "The number of retries to execute upon failure to proxy.",+ "connect_timeout": "Timeout in milliseconds for establishing a connection to the upstream server.",+ "read_timeout": "Timeout in milliseconds between two successive read operations to the upstream server.",+ "write_timeout": "Timeout in milliseconds between two successive write operations to the upstream server.",+ "tags": "Optional set of strings associated with the service for grouping and filtering.",+ "created_at": "Unix epoch (seconds) when the service was created.",+ "updated_at": "Unix epoch (seconds) when the service was last updated.",+ },+ },+ "routes": {+ "description": "Gateway routes, one row per route per control plane. Joins to api_requests on control_plane_id and route.",+ "docs_url": "https://developer.konghq.com/api/konnect/control-planes-config/v2/",+ "columns": {+ "control_plane_id": "ID of the control plane the route belongs to. Route IDs are unique only within a control plane.",+ "id": "Unique identifier of the route within its control plane.",+ "name": "The name of the route.",+ "paths": "A list of paths that match this route.",+ "methods": "A list of HTTP methods that match this route.",+ "hosts": "A list of domain names that match this route.",+ "protocols": "The protocols this route allows.",+ "headers": "Header values that cause this route to match when present in the request.",+ "expression": "Route matching expression, for routes that use the expressions router.",+ "priority": "Priority used to choose between matching expression routes.",+ "service": "The service this route proxies traffic to, as an object with the service id.",+ "strip_path": "Whether the matching path prefix is stripped from the upstream request URL.",+ "preserve_host": "Whether the request Host header is sent to the upstream.",+ "tags": "Optional set of strings associated with the route for grouping and filtering.",+ "created_at": "Unix epoch (seconds) when the route was created.",+ "updated_at": "Unix epoch (seconds) when the route was last updated.",+ },+ },+ "consumers": {+ "description": "Gateway consumers, one row per consumer per control plane. Joins to api_requests on control_plane_id and consumer.",+ "docs_url": "https://developer.konghq.com/api/konnect/control-planes-config/v2/",+ "columns": {+ "control_plane_id": "ID of the control plane the consumer belongs to. Consumer IDs are unique only within a control plane.",+ "id": "Unique identifier of the consumer within its control plane.",+ "username": "The unique username of the consumer.",+ "custom_id": "An existing unique ID for the consumer, used to map Kong consumers to users in another system.",+ "tags": "Optional set of strings associated with the consumer for grouping and filtering.",+ "created_at": "Unix epoch (seconds) when the consumer was created.",+ "updated_at": "Unix epoch (seconds) when the consumer was last updated.",+ },+ },}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/kong_konnect/kong_konnect.py b/products/warehouse_sources/backend/temporal/data_imports/sources/kong_konnect/kong_konnect.pyindex b8dea1bbe7fc..f146bd336ff0 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/kong_konnect/kong_konnect.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/kong_konnect/kong_konnect.py@@ -11,6 +11,9 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.httfrom products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManagerfrom products.warehouse_sources.backend.temporal.data_imports.sources.common.typings import SourceResponsefrom products.warehouse_sources.backend.temporal.data_imports.sources.kong_konnect.settings import (+ CONTROL_PLANE_GROUP_CLUSTER_TYPE,+ CONTROL_PLANES_PAGE_SIZE,+ CORE_ENTITY_PAGE_SIZE,DEFAULT_INITIAL_LOOKBACK_DAYS,KONG_KONNECT_ENDPOINTS,MAX_PAGE_SIZE,@@ -143,6 +146,92 @@ def _fetch_page(return response.json()+def _get_json(+ session: requests.Session,+ url: str,+ params: dict[str, Any],+ logger: FilteringBoundLogger,+ allow_not_found: bool = False,+) -> dict | None:+ # The tracked session already retries 429 and transient 5xx responses.+ response = session.get(url, params=params, timeout=REQUEST_TIMEOUT_SECONDS)++ if allow_not_found and response.status_code == 404:+ return None++ if not response.ok:+ logger.error(f"Kong Konnect API error: status={response.status_code}, body={response.text}, url={url}")+ response.raise_for_status()++ return response.json()+++def _iter_control_planes(+ session: requests.Session, base_url: str, logger: FilteringBoundLogger+) -> Iterator[list[dict[str, Any]]]:+ page_number = 1+ while True:+ params = {"page[size]": CONTROL_PLANES_PAGE_SIZE, "page[number]": page_number, "sort": "created_at"}+ data = _get_json(session, f"{base_url}/control-planes", params, logger) or {}+ control_planes = data.get("data") or []++ if control_planes:+ yield control_planes++ total = ((data.get("meta") or {}).get("page") or {}).get("total")+ if len(control_planes) < CONTROL_PLANES_PAGE_SIZE or (+ total is not None and page_number * CONTROL_PLANES_PAGE_SIZE >= total+ ):+ break+ page_number += 1+++def _iter_core_entities(+ session: requests.Session, base_url: str, path: str, logger: FilteringBoundLogger+) -> Iterator[list[dict[str, Any]]]:+ for control_planes in _iter_control_planes(session, base_url, logger):+ for control_plane in control_planes:+ if (control_plane.get("config") or {}).get("cluster_type") == CONTROL_PLANE_GROUP_CLUSTER_TYPE:+ continue++ control_plane_id = control_plane["id"]+ url = f"{base_url}/control-planes/{control_plane_id}{path}"+ offset: str | None = None+ while True:+ params: dict[str, Any] = {"size": CORE_ENTITY_PAGE_SIZE}+ if offset:+ params["offset"] = offset+ data = _get_json(session, url, params, logger, allow_not_found=True)+ if data is None:+ # The control plane was deleted between listing it and fanning out over it.+ logger.debug(f"Kong Konnect: control plane {control_plane_id} not found, skipping {path}")+ break++ rows = data.get("data") or []+ if rows:+ yield [{**row, "control_plane_id": control_plane_id} for row in rows]++ offset = data.get("offset")+ if not offset:+ break+++def get_lookup_rows(+ api_token: str,+ region: str,+ endpoint: str,+ logger: FilteringBoundLogger,+) -> Iterator[list[dict[str, Any]]]:+ endpoint_config = KONG_KONNECT_ENDPOINTS[endpoint]+ base_url = _get_base_url(region)+ session = make_tracked_session(headers=_get_headers(api_token), redact_values=(api_token,))++ if endpoint_config.kind == "control_planes":+ yield from _iter_control_planes(session, base_url, logger)+ else:+ yield from _iter_core_entities(session, base_url, endpoint_config.path, logger)++def validate_credentials(api_token: str, region: str) -> bool:"""Cheap probe that the bearer token is genuine: request a single record over a small window."""url = f"{_get_base_url(region)}/api-requests"@@ -211,9 +300,10 @@ def kong_konnect_source() -> SourceResponse:endpoint_config = KONG_KONNECT_ENDPOINTS[endpoint]- return SourceResponse(- name=endpoint,- items=lambda: get_rows(+ def items() -> Iterator[list[dict[str, Any]]]:+ if endpoint_config.kind != "analytics":+ return get_lookup_rows(api_token=api_token, region=region, endpoint=endpoint, logger=logger)+ return get_rows(api_token=api_token,region=region,endpoint=endpoint,@@ -222,7 +312,11 @@ def kong_konnect_source(should_use_incremental_field=should_use_incremental_field,db_incremental_field_last_value=db_incremental_field_last_value,lookback_days=lookback_days,- ),+ )++ return SourceResponse(+ name=endpoint,+ items=items,primary_keys=endpoint_config.primary_keys,sort_mode="asc",partition_count=1,diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/kong_konnect/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/kong_konnect/settings.pyindex 158b58a0b4cc..ead0000d4c9b 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/kong_konnect/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/kong_konnect/settings.py@@ -1,5 +1,5 @@from dataclasses import dataclass, field-from typing import Optional+from typing import Literal, Optionalfrom products.warehouse_sources.backend.types import IncrementalField, IncrementalFieldType@@ -24,8 +24,17 @@ MAX_PAGE_SIZE = 1000# on longer-retention plans can raise it; a value beyond retention is clamped by the API to what exists.DEFAULT_INITIAL_LOOKBACK_DAYS = 30+CONTROL_PLANES_PAGE_SIZE = 100-@dataclass+# Core entity list endpoints cap `size` at 1000 and paginate with an opaque `offset` token.+CORE_ENTITY_PAGE_SIZE = 1000++# A control plane group composes the config of its member control planes, which are listed (and fanned+# out over) individually, so listing entities on the group too would duplicate them.+CONTROL_PLANE_GROUP_CLUSTER_TYPE = "CLUSTER_TYPE_CONTROL_PLANE_GROUP"+++@dataclass(frozen=True)class KongKonnectEndpointConfig:name: strpath: str@@ -35,6 +44,10 @@ class KongKonnectEndpointConfig:partition_key: Optional[str] = Noneprimary_keys: list[str] = field(default_factory=lambda: ["request_id"])should_sync_default: bool = True+ # `analytics` is the time-windowed POST query; `control_planes` is the page-number list; `core_entity`+ # fans out over every control plane.+ kind: Literal["analytics", "control_planes", "core_entity"] = "analytics"+ description: Optional[str] = NoneKONG_KONNECT_ENDPOINTS: dict[str, KongKonnectEndpointConfig] = {@@ -53,6 +66,45 @@ KONG_KONNECT_ENDPOINTS: dict[str, KongKonnectEndpointConfig] = {"field_type": IncrementalFieldType.DateTime,},],+ description="Detailed records for every request proxied through the gateway (Advanced Analytics). "+ "Historical depth on initial sync is limited by your Konnect plan's data retention.",+ ),+ # Lookups that resolve the IDs carried on api_requests rows. None of these list endpoints accept a+ # timestamp filter, so they sync as full refresh.+ "control_planes": KongKonnectEndpointConfig(+ name="control_planes",+ path="/control-planes",+ kind="control_planes",+ partition_key="created_at",+ primary_keys=["id"],+ incremental_fields=[],+ description="Control planes in your Konnect organization. Resolves the control_plane ID on api_requests.",+ ),+ # Entity IDs are only guaranteed unique within a control plane (decK can copy IDs between control+ # planes), so core entities key on the control plane ID too.+ "services": KongKonnectEndpointConfig(+ name="services",+ path="/core-entities/services",+ kind="core_entity",+ primary_keys=["control_plane_id", "id"],+ incremental_fields=[],+ description="Gateway services across all control planes. Resolves the gateway_service ID on api_requests.",+ ),+ "routes": KongKonnectEndpointConfig(+ name="routes",+ path="/core-entities/routes",+ kind="core_entity",+ primary_keys=["control_plane_id", "id"],+ incremental_fields=[],+ description="Gateway routes across all control planes. Resolves the route ID on api_requests to its paths and methods.",+ ),+ "consumers": KongKonnectEndpointConfig(+ name="consumers",+ path="/core-entities/consumers",+ kind="core_entity",+ primary_keys=["control_plane_id", "id"],+ incremental_fields=[],+ description="Gateway consumers across all control planes. Resolves the consumer ID on api_requests.",),}@@ -61,3 +113,7 @@ ENDPOINTS = tuple(KONG_KONNECT_ENDPOINTS.keys())INCREMENTAL_FIELDS: dict[str, list[IncrementalField]] = {name: config.incremental_fields for name, config in KONG_KONNECT_ENDPOINTS.items()}++DESCRIPTIONS: dict[str, str] = {+ name: config.description for name, config in KONG_KONNECT_ENDPOINTS.items() if config.description+}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/kong_konnect/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/kong_konnect/source.pyindex 3f0759c9455b..eb071ee4561b 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/kong_konnect/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/kong_konnect/source.py@@ -15,7 +15,10 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.can)from products.warehouse_sources.backend.temporal.data_imports.sources.common.registry import SourceRegistryfrom products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManager-from products.warehouse_sources.backend.temporal.data_imports.sources.common.schema import SourceSchema+from products.warehouse_sources.backend.temporal.data_imports.sources.common.schema import (+ SourceSchema,+ build_endpoint_schemas,+)from products.warehouse_sources.backend.temporal.data_imports.sources.common.typings import SourceInputs, SourceResponsefrom products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs.kongkonnect import (KongKonnectSourceConfig,@@ -28,6 +31,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.kong_konne)from products.warehouse_sources.backend.temporal.data_imports.sources.kong_konnect.settings import (DEFAULT_REGION,+ DESCRIPTIONS,ENDPOINTS,INCREMENTAL_FIELDS,REGION_BASE_URLS,@@ -59,7 +63,7 @@ class KongKonnectSource(ResumableSource[KongKonnectSourceConfig, KongKonnectResucategory=DataWarehouseSourceCategory.ENGINEERING___MONITORING,label="Kong Inc. (Kong Konnect)",releaseStatus=ReleaseStatus.ALPHA,- caption="""Enter a Kong Konnect access token to pull your gateway's Advanced Analytics API request logs into the PostHog Data warehouse.+ caption="""Enter a Kong Konnect access token to pull your gateway's Advanced Analytics API request logs, plus the control planes, services, routes, and consumers they reference, into the PostHog Data warehouse.Create a **Personal Access Token** under **Konnect → Personal access tokens**, or a **System Account access token** for a service identity. Either is sent as a bearer token.@@ -115,7 +119,7 @@ How far back the initial sync can reach depends on your Konnect plan's Advanceddef get_non_retryable_errors(self) -> dict[str, str | None]:return {"401 Client Error: Unauthorized": "Your Kong Konnect access token is invalid or has expired. Create a new token in Konnect and reconnect.",- "403 Client Error: Forbidden": "Your Kong Konnect access token is missing the permissions needed to read Advanced Analytics. Grant analytics access to the token or account and reconnect.",+ "403 Client Error: Forbidden": "Your Kong Konnect access token is missing the permissions needed to read this data. Grant the token or account access to Advanced Analytics and control planes, then reconnect.",}def get_schemas(@@ -127,24 +131,7 @@ How far back the initial sync can reach depends on your Konnect plan's Advancedforce_refresh: bool = False,api_version: str | None = None,) -> list[SourceSchema]:- def _build_schema(endpoint: str) -> SourceSchema:- has_incremental = INCREMENTAL_FIELDS.get(endpoint) is not None- return SourceSchema(- name=endpoint,- # Request logs are append-only time-series; incremental sync advances an absolute- # `request_start` window each run.- supports_incremental=has_incremental,- supports_append=has_incremental,- incremental_fields=INCREMENTAL_FIELDS.get(endpoint, []),- description="Detailed records for every request proxied through the gateway (Advanced Analytics). "- "Historical depth on initial sync is limited by your Konnect plan's data retention.",- )-- schemas = [_build_schema(endpoint) for endpoint in ENDPOINTS]- if names is not None:- names_set = set(names)- schemas = [s for s in schemas if s.name in names_set]- return schemas+ return build_endpoint_schemas(ENDPOINTS, INCREMENTAL_FIELDS, names, descriptions=DESCRIPTIONS)def validate_credentials(self,diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/kong_konnect/test_kong_konnect.py b/products/warehouse_sources/backend/temporal/data_imports/sources/kong_konnect/test_kong_konnect.pyindex 65f6bc80bffc..e39cf5d761bd 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/kong_konnect/test_kong_konnect.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/kong_konnect/test_kong_konnect.py@@ -1,5 +1,6 @@+from collections.abc import Iterablefrom datetime import UTC, date, datetime-from typing import Any+from typing import Any, castimport pytestimport time_machine@@ -10,12 +11,14 @@ from parameterized import parameterizedfrom products.warehouse_sources.backend.temporal.data_imports.sources.kong_konnect import kong_konnectfrom products.warehouse_sources.backend.temporal.data_imports.sources.kong_konnect.kong_konnect import (+ CONTROL_PLANES_PAGE_SIZE,MAX_PAGE_SIZE,KongKonnectResumeConfig,_build_body,_clamp_future_value_to_now,_format_datetime,_resolve_window,+ get_lookup_rows,get_rows,kong_konnect_source,validate_credentials,@@ -189,5 +192,100 @@ class TestKongKonnectSourceResponse:assert response.partition_keys == ["request_start"]+def _json_response(status: int, body: dict[str, Any] | None = None) -> MagicMock:+ response = MagicMock()+ response.status_code = status+ response.ok = status < 400+ response.json.return_value = body or {}+ if status >= 400:+ response.raise_for_status.side_effect = requests.HTTPError(f"{status} Client Error", response=response)+ return response+++def _control_plane(cp_id: str, cluster_type: str = "CLUSTER_TYPE_CONTROL_PLANE") -> dict[str, Any]:+ return {"id": cp_id, "name": cp_id, "config": {"cluster_type": cluster_type}}+++BASE = "https://us.api.konghq.com/v2"+++class TestLookupRows:+ @parameterized.expand(+ [+ ("short_page_stops", [[CONTROL_PLANES_PAGE_SIZE, None], [2, None]], 2),+ ("total_reached_stops", [[CONTROL_PLANES_PAGE_SIZE, CONTROL_PLANES_PAGE_SIZE]], 1),+ ("empty_first_page", [[0, 0]], 1),+ ]+ )+ @patch.object(kong_konnect, "make_tracked_session")+ def test_control_planes_page_number_pagination(+ self, _name: str, pages: list[list[int | None]], expected_requests: int, mock_session: MagicMock+ ) -> None:+ responses = []+ for count, total in pages:+ meta = {"page": {"total": total}} if total is not None else {}+ responses.append(+ _json_response(200, {"data": [_control_plane(f"cp{i}") for i in range(count or 0)], "meta": meta})+ )+ mock_session.return_value.get.side_effect = responses++ rows = [row for batch in get_lookup_rows("tok", "us", "control_planes", MagicMock()) for row in batch]++ assert len(rows) == sum(count or 0 for count, _ in pages)+ calls = mock_session.return_value.get.call_args_list+ assert len(calls) == expected_requests+ assert [c.kwargs["params"]["page[number]"] for c in calls] == list(range(1, expected_requests + 1))++ @patch.object(kong_konnect, "make_tracked_session")+ def test_core_entities_fan_out_over_control_planes(self, mock_session: MagicMock) -> None:+ def fake_get(url: str, params: dict[str, Any], timeout: int) -> MagicMock:+ if url == f"{BASE}/control-planes":+ return _json_response(+ 200,+ {+ "data": [+ _control_plane("cp-a"),+ _control_plane("cp-group", "CLUSTER_TYPE_CONTROL_PLANE_GROUP"),+ _control_plane("cp-deleted"),+ _control_plane("cp-b"),+ ],+ "meta": {"page": {"total": 4}},+ },+ )+ if url == f"{BASE}/control-planes/cp-a/core-entities/services":+ if params.get("offset") == "next-token":+ return _json_response(200, {"data": [{"id": "svc-2"}], "offset": None})+ return _json_response(200, {"data": [{"id": "svc-1"}], "offset": "next-token"})+ if url == f"{BASE}/control-planes/cp-deleted/core-entities/services":+ return _json_response(404)+ if url == f"{BASE}/control-planes/cp-b/core-entities/services":+ # decK can copy entity IDs between control planes, so the same ID shows up again here.+ return _json_response(200, {"data": [{"id": "svc-1"}]})+ raise AssertionError(f"unexpected request to {url}")++ mock_session.return_value.get.side_effect = fake_get++ response = kong_konnect_source("tok", "us", "services", MagicMock(), _manager())+ rows = [row for batch in cast(Iterable[list[dict[str, Any]]], response.items()) for row in batch]++ assert rows == [+ {"id": "svc-1", "control_plane_id": "cp-a"},+ {"id": "svc-2", "control_plane_id": "cp-a"},+ {"id": "svc-1", "control_plane_id": "cp-b"},+ ]+ assert response.primary_keys == ["control_plane_id", "id"]+ mock_session.return_value.post.assert_not_called()++ @patch.object(kong_konnect, "make_tracked_session")+ def test_core_entities_raise_on_auth_error(self, mock_session: MagicMock) -> None:+ mock_session.return_value.get.side_effect = [+ _json_response(200, {"data": [_control_plane("cp-a")], "meta": {"page": {"total": 1}}}),+ _json_response(403),+ ]++ with pytest.raises(requests.HTTPError):+ list(get_lookup_rows("tok", "us", "consumers", MagicMock()))++if __name__ == "__main__":pytest.main([__file__])diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/kong_konnect/test_kong_konnect_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/kong_konnect/test_kong_konnect_source.pyindex 0b69f456b880..84fb4300552c 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/kong_konnect/test_kong_konnect_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/kong_konnect/test_kong_konnect_source.py@@ -38,12 +38,14 @@ class TestSourceConfig:class TestGetSchemas:- def test_api_requests_supports_incremental(self) -> None:- schemas = KongKonnectSource().get_schemas(_config(), team_id=1)- assert [s.name for s in schemas] == ["api_requests"]- schema = schemas[0]- assert schema.supports_incremental is True- assert [f["field"] for f in schema.incremental_fields] == ["request_start"]+ def test_only_api_requests_supports_incremental(self) -> None:+ schemas = {s.name: s for s in KongKonnectSource().get_schemas(_config(), team_id=1)}+ assert schemas["api_requests"].supports_incremental is True+ assert [f["field"] for f in schemas["api_requests"].incremental_fields] == ["request_start"]+ # The lookup list endpoints have no server-side timestamp filter, so they must stay full refresh.+ for name in ("control_planes", "services", "routes", "consumers"):+ assert schemas[name].supports_incremental is False+ assert schemas[name].supports_append is Falsedef test_names_filter(self) -> None:assert KongKonnectSource().get_schemas(_config(), team_id=1, names=["nonexistent"]) == []@@ -52,7 +54,7 @@ class TestGetSchemas:# Static catalog → public docs render the table list.assert KongKonnectSource.lists_tables_without_credentials is Truetables = KongKonnectSource().get_documented_tables()- assert [t["name"] for t in tables] == ["api_requests"]+ assert [t["name"] for t in tables] == ["api_requests", "control_planes", "services", "routes", "consumers"]class TestValidateCredentials: