: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(data-warehouse): implement airops import source (#69993)
Tom Owers646673e65a55
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.md b/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.mdindex e062b60c79d7..54df75f1cb66 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.md+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.md@@ -48,6 +48,7 @@ the row lists both.| agilecrm | HTTP | requests | ✅ || aha | HTTP | requests | ✅ || aircall | HTTP | requests | ✅ |+| airops | HTTP | requests | ✅ || airtable | HTTP | requests | ✅ || algolia | HTTP | requests | ✅ || alguna | HTTP | requests | ✅ |@@ -474,7 +475,6 @@ doesn't conflict with concurrent PRs.- ahrefs- aikido_security- airbyte-- airops- aiven- akeneo- alpaca_broker_apidiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/airops/airops.py b/products/warehouse_sources/backend/temporal/data_imports/sources/airops/airops.pynew file mode 100644index 000000000000..f7c784ad82f8--- /dev/null+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/airops/airops.py@@ -0,0 +1,151 @@+from collections.abc import Iterator+from typing import Any+from urllib.parse import urlencode++import requests+from structlog.types import FilteringBoundLogger+from tenacity import retry, retry_if_exception_type, stop_after_attempt, wait_exponential_jitter++from products.warehouse_sources.backend.temporal.data_imports.pipelines.pipeline.typings import SourceResponse+from products.warehouse_sources.backend.temporal.data_imports.sources.airops.settings import AIROPS_ENDPOINTS+from products.warehouse_sources.backend.temporal.data_imports.sources.common.http import make_tracked_session++AIROPS_BASE_URL = "https://api.airops.com"+# The executions endpoint caps `items` at 100.+EXECUTIONS_PAGE_SIZE = 100+++class AirOpsRetryableError(Exception):+ """Raised for AirOps responses that are safe to retry (429 / 5xx)."""+++def _get_headers(api_key: str) -> dict[str, str]:+ return {+ "Authorization": f"Bearer {api_key}",+ "Accept": "application/json",+ }+++def _make_session(api_key: str) -> requests.Session:+ """Session for all AirOps traffic. The bearer token is set once on the session (so its redaction+ policy applies to every request and captured sample) and redirects are pinned off so a credentialed+ request can't be replayed against another host. Response capture is disabled because executions+ carry free-form `inputs`/`output` under arbitrary keys — a user can place credentials or other+ secrets there, and the name-based sample scrubbers can't reliably recognise them."""+ return make_tracked_session(+ headers=_get_headers(api_key),+ redact_values=(api_key,),+ allow_redirects=False,+ capture=False,+ )+++@retry(+ retry=retry_if_exception_type(+ (+ AirOpsRetryableError,+ requests.ReadTimeout,+ requests.ConnectionError,+ requests.exceptions.ChunkedEncodingError,+ )+ ),+ stop=stop_after_attempt(5),+ wait=wait_exponential_jitter(initial=1, max=30),+ reraise=True,+)+def _fetch_json(session: requests.Session, url: str, logger: FilteringBoundLogger) -> Any:+ response = session.get(url, timeout=60)++ if response.status_code == 429 or response.status_code >= 500:+ raise AirOpsRetryableError(f"AirOps API error (retryable): status={response.status_code}, url={url}")++ if not response.ok:+ logger.error(f"AirOps API error: status={response.status_code}, body={response.text}, url={url}")+ response.raise_for_status()++ return response.json()+++def _iter_apps(session: requests.Session, logger: FilteringBoundLogger) -> Iterator[dict]:+ """List every app. The apps endpoint returns a plain (unwrapped) JSON array with no pagination."""+ data = _fetch_json(session, f"{AIROPS_BASE_URL}/public_api/airops_apps", logger)+ if not isinstance(data, list):+ # Defensive: the docs describe a bare array, but tolerate a `{data: [...]}` envelope if the+ # beta API ever wraps it, rather than crashing the sync.+ data = data.get("data", []) if isinstance(data, dict) else []+ yield from data+++def _get_apps(session: requests.Session, logger: FilteringBoundLogger) -> Iterator[list[dict]]:+ apps = list(_iter_apps(session, logger))+ if apps:+ yield apps+++def _get_executions(session: requests.Session, logger: FilteringBoundLogger) -> Iterator[list[dict]]:+ """Fan out over every app and page through its executions.++ Executions can only be listed per app, so we enumerate apps first and follow each app's+ cursor-paginated executions endpoint. Each row is stamped with `airops_app_id` so the flattened+ table can be joined back to its parent app (and so the primary key stays meaningful table-wide).+ """+ for app in _iter_apps(session, logger):+ # The app id is required to reach the child endpoint; a missing id means we'd silently drop an+ # app's executions, so fail loudly rather than sync partial data.+ app_id = app["id"]++ cursor: str | None = None+ while True:+ params: dict[str, Any] = {"airops_app_id": app_id, "items": EXECUTIONS_PAGE_SIZE}+ if cursor:+ params["cursor"] = cursor+ url = f"{AIROPS_BASE_URL}/public_api/airops_apps/{app_id}/executions?{urlencode(params)}"++ data = _fetch_json(session, url, logger)+ records = data.get("data", []) if isinstance(data, dict) else []+ for record in records:+ record["airops_app_id"] = app_id+ if records:+ yield records++ meta = data.get("meta", {}) if isinstance(data, dict) else {}+ cursor = meta.get("cursor")+ # Keep paging while a cursor is present. Only stop when the cursor runs out or `has_more`+ # is explicitly false, so a response that returns a cursor without `has_more` isn't dropped.+ if not cursor or meta.get("has_more") is False:+ break+++def get_rows(api_key: str, endpoint: str, logger: FilteringBoundLogger) -> Iterator[list[dict]]:+ session = _make_session(api_key)++ if endpoint == "apps":+ yield from _get_apps(session, logger)+ elif endpoint == "executions":+ yield from _get_executions(session, logger)+ else:+ raise ValueError(f"Unknown AirOps endpoint: {endpoint}")+++def airops_source(api_key: str, endpoint: str, logger: FilteringBoundLogger) -> SourceResponse:+ endpoint_config = AIROPS_ENDPOINTS[endpoint]++ return SourceResponse(+ name=endpoint,+ items=lambda: get_rows(api_key=api_key, endpoint=endpoint, logger=logger),+ primary_keys=endpoint_config.primary_keys,+ partition_count=1,+ partition_size=1,+ partition_mode="datetime" if endpoint_config.partition_key else None,+ partition_format="month" if endpoint_config.partition_key else None,+ partition_keys=[endpoint_config.partition_key] if endpoint_config.partition_key else None,+ )+++def validate_credentials(api_key: str) -> bool:+ """Cheapest probe that confirms the workspace API key is genuine: list apps and check for a 200."""+ try:+ response = _make_session(api_key).get(f"{AIROPS_BASE_URL}/public_api/airops_apps", timeout=10)+ return response.status_code == 200+ except Exception:+ return Falsediff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/airops/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/airops/canonical_descriptions.pynew file mode 100644index 000000000000..f5c7d730fbd3--- /dev/null+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/airops/canonical_descriptions.py@@ -0,0 +1,47 @@+from products.warehouse_sources.backend.temporal.data_imports.sources.common.canonical_descriptions import (+ CanonicalDescriptions,+)++# Descriptions sourced from the AirOps public API reference (https://docs.airops.com/api-reference).+CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {+ "apps": {+ "description": "An AirOps app (workflow or agent) in your workspace.",+ "docs_url": "https://docs.airops.com/api-reference/api-reference/apps",+ "columns": {+ "id": "Unique identifier for the app.",+ "uuid": "Globally unique 36-character identifier for the app.",+ "name": "Human-readable name of the app.",+ "description": "Description of what the app does.",+ "readme": "Long-form README/documentation for the app.",+ "emoji": "Emoji shown as the app's icon.",+ "background_color": "Background color used for the app's icon.",+ "public": "Whether the app is publicly accessible.",+ "active_version_id": "Identifier of the app version currently published as active.",+ "created_at": "Timestamp when the app was created.",+ "updated_at": "Timestamp when the app was last updated.",+ },+ },+ "executions": {+ "description": "A single run of an AirOps app, including its inputs, output, and run metadata.",+ "docs_url": "https://docs.airops.com/api-reference/api-reference/executions",+ "columns": {+ "id": "Unique identifier for the execution.",+ "uuid": "Globally unique 36-character identifier for the execution.",+ "airops_app_id": "Identifier of the parent app this execution belongs to.",+ "airops_apps_version_id": "Identifier of the app version that produced this execution.",+ "workspace_id": "Identifier of the workspace the execution ran in.",+ "conversation_id": "Identifier of the conversation this execution is part of, when applicable.",+ "status": "Execution status: pending, running, error, success, cancelled, or review_needed.",+ "inputs": "Free-form JSON object of the inputs the app was run with.",+ "output": "Free-form JSON object of the app's output.",+ "credits_used": "Number of AirOps credits consumed by the execution.",+ "runtime": "Time it took to execute the app, in seconds.",+ "source": "Where the execution was triggered from.",+ "feedback": "User feedback on the execution: positive, neutral, or negative.",+ "error_code": "Error code when the execution failed.",+ "error_message": "Error message when the execution failed.",+ "createdAt": "Timestamp when the execution was created.",+ "updatedAt": "Timestamp when the execution was last updated.",+ },+ },+}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/airops/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/airops/settings.pynew file mode 100644index 000000000000..b9e9f7192cfe--- /dev/null+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/airops/settings.py@@ -0,0 +1,38 @@+from dataclasses import dataclass, field+from typing import Optional++from products.warehouse_sources.backend.types import IncrementalField+++@dataclass+class AirOpsEndpointConfig:+ name: str+ # Partition on a STABLE creation timestamp so partitions don't rewrite on every sync. Apps expose+ # `created_at`; executions expose `createdAt`.+ partition_key: Optional[str] = None+ primary_keys: list[str] = field(default_factory=lambda: ["id"])+ # AirOps exposes no server-side timestamp filter on either list endpoint, and executions mutate+ # after creation (status transitions, feedback), so every endpoint is full refresh only.+ incremental_fields: list[IncrementalField] = field(default_factory=list)+ should_sync_default: bool = True+++AIROPS_ENDPOINTS: dict[str, AirOpsEndpointConfig] = {+ "apps": AirOpsEndpointConfig(+ name="apps",+ partition_key="created_at",+ ),+ "executions": AirOpsEndpointConfig(+ name="executions",+ partition_key="createdAt",+ # Execution ids are scoped per app, so the app id is part of the composite key to keep two+ # apps' executions that share an id from colliding into one warehouse row.+ primary_keys=["airops_app_id", "id"],+ ),+}++ENDPOINTS = tuple(AIROPS_ENDPOINTS.keys())++INCREMENTAL_FIELDS: dict[str, list[IncrementalField]] = {+ name: config.incremental_fields for name, config in AIROPS_ENDPOINTS.items()+}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/airops/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/airops/source.pyindex 0d29a4f5f4e0..f9956accbb93 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/airops/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/airops/source.py@@ -1,19 +1,40 @@-from typing import cast+from typing import Optional, castfrom posthog.schema import (DataWarehouseSourceCategory,ExternalDataSourceType as SchemaExternalDataSourceType,+ ReleaseStatus,SourceConfig,+ SourceFieldInputConfig,+ SourceFieldInputConfigType,)+from products.warehouse_sources.backend.temporal.data_imports.pipelines.pipeline.typings import (+ SourceInputs,+ SourceResponse,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.airops.airops import (+ airops_source,+ validate_credentials as validate_airops_credentials,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.airops.settings import (+ ENDPOINTS,+ INCREMENTAL_FIELDS,+)from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import FieldType, SimpleSource+from products.warehouse_sources.backend.temporal.data_imports.sources.common.canonical_descriptions import (+ CanonicalDescriptions,+)from products.warehouse_sources.backend.temporal.data_imports.sources.common.registry import SourceRegistry+from products.warehouse_sources.backend.temporal.data_imports.sources.common.schema import SourceSchemafrom products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs import AirOpsSourceConfigfrom products.warehouse_sources.backend.types import ExternalDataSourceType@SourceRegistry.registerclass AirOpsSource(SimpleSource[AirOpsSourceConfig]):+ lists_tables_without_credentials = True # static endpoint catalog — safe for public docs+@propertydef source_type(self) -> ExternalDataSourceType:return ExternalDataSourceType.AIROPS@@ -24,7 +45,77 @@ class AirOpsSource(SimpleSource[AirOpsSourceConfig]):name=SchemaExternalDataSourceType.AIR_OPS,category=DataWarehouseSourceCategory.ENGINEERING___MONITORING,label="AirOps",+ releaseStatus=ReleaseStatus.ALPHA,+ caption="""Enter your AirOps workspace API key to sync your AirOps apps and their executions into the PostHog Data warehouse.++You can create a workspace API key in your [AirOps workspace settings](https://app.airops.com). Regenerating the key immediately invalidates the previous one.""",iconPath="/static/services/airops.png",- fields=cast(list[FieldType], []),- unreleasedSource=True,+ docsUrl="https://posthog.com/docs/cdp/sources/airops",+ fields=cast(+ list[FieldType],+ [+ SourceFieldInputConfig(+ name="api_key",+ label="API key",+ type=SourceFieldInputConfigType.PASSWORD,+ required=True,+ placeholder="",+ secret=True,+ ),+ ],+ ),+ )++ def get_canonical_descriptions(self) -> CanonicalDescriptions:+ from products.warehouse_sources.backend.temporal.data_imports.sources.airops.canonical_descriptions import (+ CANONICAL_DESCRIPTIONS,+ )++ return CANONICAL_DESCRIPTIONS++ def get_non_retryable_errors(self) -> dict[str, str | None]:+ return {+ # A missing, invalid, or regenerated workspace key surfaces as a requests HTTPError once+ # `_fetch_json` calls `raise_for_status()`. No retry can fix a credential problem, so stop+ # the sync. Match the stable status text and base host, not the per-request path/query.+ "401 Client Error: Unauthorized for url: https://api.airops.com": "Your AirOps API key is invalid or has been regenerated. Create a new workspace API key in your AirOps settings, then reconnect.",+ "403 Client Error: Forbidden for url: https://api.airops.com": "Your AirOps API key does not have access to this data. Check the key's workspace permissions, then reconnect.",+ }++ def get_schemas(+ self,+ config: AirOpsSourceConfig,+ team_id: int,+ with_counts: bool = False,+ names: list[str] | None = None,+ force_refresh: bool = False,+ ) -> list[SourceSchema]:+ # AirOps has no server-side timestamp filter and executions mutate after creation, so every+ # table is full refresh only (no incremental / append support).+ schemas = [+ SourceSchema(+ name=endpoint,+ supports_incremental=False,+ supports_append=False,+ incremental_fields=INCREMENTAL_FIELDS.get(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++ def validate_credentials(+ self, config: AirOpsSourceConfig, team_id: int, schema_name: Optional[str] = None+ ) -> tuple[bool, str | None]:+ if validate_airops_credentials(config.api_key):+ return True, None+ return False, "Invalid AirOps API key"++ def source_for_pipeline(self, config: AirOpsSourceConfig, inputs: SourceInputs) -> SourceResponse:+ return airops_source(+ api_key=config.api_key,+ endpoint=inputs.schema_name,+ logger=inputs.logger,)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/airops/tests/test_airops.py b/products/warehouse_sources/backend/temporal/data_imports/sources/airops/tests/test_airops.pynew file mode 100644index 000000000000..6377476c7aa8--- /dev/null+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/airops/tests/test_airops.py@@ -0,0 +1,186 @@+import json+from typing import Any++import pytest+from unittest.mock import MagicMock, patch++import requests+from requests import Response++from products.warehouse_sources.backend.temporal.data_imports.sources.airops.airops import (+ AirOpsRetryableError,+ _fetch_json,+ _make_session,+ airops_source,+ get_rows,+ validate_credentials,+)+++def _response(body: Any, status: int = 200, url: str = "https://api.airops.com/public_api/airops_apps") -> Response:+ resp = Response()+ resp.status_code = status+ resp._content = json.dumps(body).encode()+ resp.url = url+ resp.headers["Content-Type"] = "application/json"+ return resp+++def _run(endpoint: str, responses: list[Response]) -> tuple[list[list[dict]], MagicMock]:+ session = MagicMock()+ session.get.side_effect = responses+ with patch(+ "products.warehouse_sources.backend.temporal.data_imports.sources.airops.airops.make_tracked_session",+ return_value=session,+ ):+ batches = list(get_rows(api_key="k", endpoint=endpoint, logger=MagicMock()))+ return batches, session+++class TestMakeSession:+ def test_disables_sample_capture_and_redirects(self) -> None:+ # Executions carry free-form inputs/output that can hold user secrets the name-based+ # scrubbers can't recognise, so response capture must stay off; redirects stay pinned off+ # so a credentialed request can't be replayed against another host.+ with patch(+ "products.warehouse_sources.backend.temporal.data_imports.sources.airops.airops.make_tracked_session"+ ) as make_session:+ _make_session("secret-key")+ assert make_session.call_args.kwargs["capture"] is False+ assert make_session.call_args.kwargs["allow_redirects"] is False+ assert make_session.call_args.kwargs["redact_values"] == ("secret-key",)+++class TestGetApps:+ def test_yields_the_unwrapped_array(self) -> None:+ batches, session = _run("apps", [_response([{"id": 1, "name": "A"}, {"id": 2, "name": "B"}])])+ assert batches == [[{"id": 1, "name": "A"}, {"id": 2, "name": "B"}]]+ assert session.get.call_count == 1++ def test_tolerates_data_envelope(self) -> None:+ # Defensive fallback: the docs describe a bare array, but a beta API could wrap it.+ batches, _ = _run("apps", [_response({"data": [{"id": 1}]})])+ assert batches == [[{"id": 1}]]++ def test_empty_apps_yields_nothing(self) -> None:+ batches, _ = _run("apps", [_response([])])+ assert batches == []+++class TestGetExecutions:+ def test_fans_out_over_apps_and_paginates(self) -> None:+ responses = [+ _response([{"id": 10}, {"id": 20}]), # apps+ _response({"data": [{"id": "e1"}], "meta": {"has_more": True, "cursor": "c1"}}), # app 10 page 1+ _response({"data": [{"id": "e2"}], "meta": {"has_more": False, "cursor": None}}), # app 10 page 2+ _response({"data": [{"id": "e3"}], "meta": {"has_more": False}}), # app 20 page 1+ ]+ batches, session = _run("executions", responses)++ rows = [row for batch in batches for row in batch]+ # Every execution row is stamped with its parent app id so the flattened table can be joined+ # back and the primary key stays meaningful table-wide.+ assert rows == [+ {"id": "e1", "airops_app_id": 10},+ {"id": "e2", "airops_app_id": 10},+ {"id": "e3", "airops_app_id": 20},+ ]+ # 1 apps call + 2 pages for app 10 + 1 page for app 20.+ assert session.get.call_count == 4+ # The second page carries the cursor returned by the first.+ page_two_url = session.get.call_args_list[2].args[0]+ assert "cursor=c1" in page_two_url++ def test_stops_when_cursor_missing_even_if_has_more_true(self) -> None:+ # A truthy has_more with no cursor would otherwise loop forever re-fetching page one.+ responses = [+ _response([{"id": 10}]),+ _response({"data": [{"id": "e1"}], "meta": {"has_more": True}}),+ ]+ batches, session = _run("executions", responses)+ assert [row for batch in batches for row in batch] == [{"id": "e1", "airops_app_id": 10}]+ assert session.get.call_count == 2++ def test_fails_when_app_missing_id(self) -> None:+ # A missing app id must fail loudly rather than silently dropping that app's executions.+ responses = [_response([{"name": "no id"}])]+ with pytest.raises(KeyError):+ _run("executions", responses)++ def test_paginates_when_cursor_present_without_has_more(self) -> None:+ # A response with a cursor but no has_more flag must still page to the next cursor.+ responses = [+ _response([{"id": 10}]),+ _response({"data": [{"id": "e1"}], "meta": {"cursor": "c1"}}),+ _response({"data": [{"id": "e2"}], "meta": {"has_more": False}}),+ ]+ batches, session = _run("executions", responses)+ assert [row for batch in batches for row in batch] == [+ {"id": "e1", "airops_app_id": 10},+ {"id": "e2", "airops_app_id": 10},+ ]+ assert session.get.call_count == 3+++class TestGetRowsUnknownEndpoint:+ def test_raises_for_unknown_endpoint(self) -> None:+ with pytest.raises(ValueError, match="Unknown AirOps endpoint"):+ list(get_rows(api_key="k", endpoint="nope", logger=MagicMock()))+++class TestFetchJsonStatusHandling:+ @pytest.mark.parametrize("status", [429, 500, 503])+ def test_retryable_statuses_raise_retryable_error(self, status: int) -> None:+ session = MagicMock()+ session.get.return_value = _response({}, status=status)+ # Call the undecorated function so tenacity's retry/backoff doesn't sleep in the test.+ with pytest.raises(AirOpsRetryableError):+ _fetch_json.__wrapped__(session, "https://api.airops.com/x", MagicMock()) # type: ignore[attr-defined]++ @pytest.mark.parametrize("status", [400, 401, 403, 404])+ def test_client_errors_propagate_as_httperror(self, status: int) -> None:+ # 4xx (bad/expired credentials, missing app) must surface as HTTPError so+ # get_non_retryable_errors can match and permanently fail the sync.+ session = MagicMock()+ session.get.return_value = _response({"error": "nope"}, status=status)+ with pytest.raises(requests.HTTPError):+ _fetch_json.__wrapped__(session, "https://api.airops.com/x", MagicMock()) # type: ignore[attr-defined]+++class TestValidateCredentials:+ @pytest.mark.parametrize(("status", "expected"), [(200, True), (401, False), (403, False)])+ def test_maps_status_to_bool(self, status: int, expected: bool) -> None:+ session = MagicMock()+ session.get.return_value = _response({}, status=status)+ with patch(+ "products.warehouse_sources.backend.temporal.data_imports.sources.airops.airops.make_tracked_session",+ return_value=session,+ ):+ assert validate_credentials("key") is expected++ def test_network_failure_is_false(self) -> None:+ session = MagicMock()+ session.get.side_effect = requests.ConnectionError("boom")+ with patch(+ "products.warehouse_sources.backend.temporal.data_imports.sources.airops.airops.make_tracked_session",+ return_value=session,+ ):+ assert validate_credentials("key") is False+++class TestAirOpsSourceResponse:+ @pytest.mark.parametrize(+ ("endpoint", "partition_key", "primary_keys"),+ [+ ("apps", "created_at", ["id"]),+ # Executions are keyed by (app id, id) because execution ids are scoped per app.+ ("executions", "createdAt", ["airops_app_id", "id"]),+ ],+ )+ def test_partition_and_primary_keys(self, endpoint: str, partition_key: str, primary_keys: list[str]) -> None:+ # Partition on a STABLE creation timestamp (never updated_at), which differs per endpoint.+ response = airops_source(api_key="k", endpoint=endpoint, logger=MagicMock())+ assert response.name == endpoint+ assert response.primary_keys == primary_keys+ assert response.partition_keys == [partition_key]+ assert response.partition_mode == "datetime"diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/airops/tests/test_airops_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/airops/tests/test_airops_source.pynew file mode 100644index 000000000000..a862428967a1--- /dev/null+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/airops/tests/test_airops_source.py@@ -0,0 +1,105 @@+from typing import Any++from unittest.mock import MagicMock, patch++from parameterized import parameterized++from posthog.schema import DataWarehouseSourceCategory, ReleaseStatus, SourceFieldInputConfig++from products.warehouse_sources.backend.temporal.data_imports.pipelines.pipeline.typings import SourceInputs+from products.warehouse_sources.backend.temporal.data_imports.sources.airops.source import AirOpsSource+from products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs import AirOpsSourceConfig+from products.warehouse_sources.backend.types import ExternalDataSourceType+++def _config(api_key: str = "test-key") -> AirOpsSourceConfig:+ return AirOpsSourceConfig.from_dict({"api_key": api_key})+++def _inputs(schema_name: str) -> SourceInputs:+ return SourceInputs(+ schema_name=schema_name,+ schema_id="schema-1",+ source_id="source-1",+ team_id=1,+ should_use_incremental_field=False,+ db_incremental_field_last_value=None,+ db_incremental_field_earliest_value=None,+ incremental_field=None,+ incremental_field_type=None,+ job_id="job-1",+ logger=MagicMock(),+ reset_pipeline=False,+ )+++class TestAirOpsSource:+ def test_source_type(self) -> None:+ assert AirOpsSource().source_type == ExternalDataSourceType.AIROPS++ def test_source_config_shape(self) -> None:+ config = AirOpsSource().get_source_config+ assert config.category == DataWarehouseSourceCategory.ENGINEERING___MONITORING+ assert config.releaseStatus == ReleaseStatus.ALPHA+ assert config.docsUrl == "https://posthog.com/docs/cdp/sources/airops"+ # The single credential field must be a secret so it isn't echoed back to the client.+ field_names = {f.name for f in config.fields}+ assert field_names == {"api_key"}+ api_key_field = config.fields[0]+ assert isinstance(api_key_field, SourceFieldInputConfig)+ assert api_key_field.secret is True++ def test_get_schemas_are_full_refresh_only(self) -> None:+ # AirOps exposes no server-side timestamp filter and executions mutate after creation, so+ # neither table may advertise incremental/append — that would silently drop mutated rows.+ schemas = AirOpsSource().get_schemas(_config(), team_id=1)+ assert {s.name for s in schemas} == {"apps", "executions"}+ for schema in schemas:+ assert schema.supports_incremental is False+ assert schema.supports_append is False+ assert schema.incremental_fields == []++ def test_get_schemas_filters_by_name(self) -> None:+ schemas = AirOpsSource().get_schemas(_config(), team_id=1, names=["executions"])+ assert [s.name for s in schemas] == ["executions"]++ @parameterized.expand([("valid", True, (True, None)), ("invalid", False, (False, "Invalid AirOps API key"))])+ def test_validate_credentials(self, _name: str, probe_result: bool, expected: tuple[bool, str | None]) -> None:+ with patch(+ "products.warehouse_sources.backend.temporal.data_imports.sources.airops.source.validate_airops_credentials",+ return_value=probe_result,+ ):+ assert AirOpsSource().validate_credentials(_config(), team_id=1) == expected++ @parameterized.expand(+ [+ ("401 Client Error: Unauthorized for url: https://api.airops.com/public_api/airops_apps",),+ ("403 Client Error: Forbidden for url: https://api.airops.com/public_api/airops_apps",),+ ]+ )+ def test_non_retryable_errors_match_credential_failures(self, raised_message: str) -> None:+ # A revoked/regenerated key must permanently fail the sync rather than retry forever; the+ # matcher keys on the stable status text + base host, so a real HTTPError string matches.+ errors = AirOpsSource().get_non_retryable_errors()+ assert any(pattern in raised_message and friendly for pattern, friendly in errors.items())++ def test_source_for_pipeline_plumbs_arguments(self) -> None:+ sentinel = object()+ with patch(+ "products.warehouse_sources.backend.temporal.data_imports.sources.airops.source.airops_source",+ return_value=sentinel,+ ) as mock_source:+ inputs = _inputs("executions")+ result = AirOpsSource().source_for_pipeline(_config("key-123"), inputs)++ assert result is sentinel+ mock_source.assert_called_once_with(api_key="key-123", endpoint="executions", logger=inputs.logger)++ def test_documented_tables_render_without_credentials(self) -> None:+ # `lists_tables_without_credentials=True` powers the public docs table catalog; it must resolve+ # from the static endpoint catalog with no network call and merge canonical descriptions.+ tables = AirOpsSource().get_documented_tables()+ by_name: dict[str, dict[str, Any]] = {t["name"]: t for t in tables}+ assert set(by_name) == {"apps", "executions"}+ assert by_name["apps"]["sync_methods"] == ["Full refresh"]+ assert by_name["executions"]["description"]diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs.py b/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs.pyindex b39e4dd7363e..9a26500f616f 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs.py@@ -186,7 +186,7 @@ class AikidoSecuritySourceConfig(config.Config):@config.configclass AirOpsSourceConfig(config.Config):- pass+ api_key: str@config.config