: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): add four missing Fly.io tables (#108373)
Tom Owersa9aa9bd7b848
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 a21c9e153053..c3e7bdd6593e 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@@ -3293,17 +3293,17 @@ Note: developers.flowlu.com is the API host, not docs (returns 404/api-key error## FlyIo — gaps-Today (3): `apps`, `machines`, `volumes`+Today (7): `apps`, `machine_events`, `machine_versions`, `machines`, `regions`, `volume_snapshots`, `volumes`Diffed against: <https://docs.machines.dev/spec/openapi3.json>-- [ ] `/apps/{app_name}/machines/{machine_id}/events` — machine state-transition history (start/stop/OOM/restart) - the only way to analyze uptime and crash patterns (high)-- [ ] `/platform/regions` — lookup resolving the region codes already carried on machines and volumes (medium)-- [ ] `/apps/{app_name}/machines/{machine_id}/versions` — per-machine config version history, gives deploy/rollout timeline (medium)-- [ ] `/apps/{app_name}/volumes/{volume_id}/snapshots` — snapshot history per volume for backup coverage reporting (medium)+- [x] `/apps/{app_name}/machines/{machine_id}/events` — machine state-transition history (start/stop/OOM/restart) - the only way to analyze uptime and crash patterns (high)+- [x] `/platform/regions` — lookup resolving the region codes already carried on machines and volumes (medium)+- [x] `/apps/{app_name}/machines/{machine_id}/versions` — per-machine config version history, gives deploy/rollout timeline (medium)+- [x] `/apps/{app_name}/volumes/{volume_id}/snapshots` — snapshot history per volume for backup coverage reporting (medium)- [ ] `/postgres` — managed Postgres cluster inventory (plus /postgres/{id}/databases) missing from the infra picture (low)-Note: PostHog syncs machines/volumes via the org-wide /orgs/{org_slug}/... routes; events and versions only exist per-machine, so they need a fan-out over the machines table. secrets/secretkeys, certificates and lease endpoints excluded as plumbing.+Note: PostHog syncs machines/volumes via the org-wide /orgs/{org_slug}/... routes. Events, versions and volume snapshots only exist per app resource, so each fans out over its org-wide parent listing and carries the parent's app name and id onto every row. Those three endpoints return a bare array with no cursor, so each sync stores the history the API returns at that moment. secrets/secretkeys, certificates and lease endpoints excluded as plumbing.## Formbricks — gapsdiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/fly_io/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/fly_io/canonical_descriptions.pyindex 3d742613a8d3..6c60c1f71e13 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/fly_io/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/fly_io/canonical_descriptions.py@@ -65,4 +65,58 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"updated_at": "Timestamp the volume was last updated (RFC 3339).",},},+ "regions": {+ "description": "Fly.io platform regions, the lookup that resolves the region codes carried on machines and volumes.",+ "docs_url": "https://fly.io/docs/reference/regions/",+ "columns": {+ "code": "Three-letter region code (e.g. iad, lhr, syd). This is what machine and volume rows carry in their `region` column.",+ "name": "Human-readable region name (e.g. Ashburn, Virginia (US)).",+ "geo_region": "Broader geographic grouping the region belongs to.",+ "latitude": "Latitude of the region.",+ "longitude": "Longitude of the region.",+ "deprecated": "Whether the region is deprecated and no longer accepts new workloads.",+ "gateway_available": "Whether a WireGuard gateway is available in the region.",+ "mpg_available": "Whether Fly Managed Postgres is available in the region.",+ "requires_paid_plan": "Whether deploying to the region requires a paid plan.",+ },+ },+ "machine_events": {+ "description": "State-transition history per machine (start, stop, restart, exit, out-of-memory), the record of how each machine behaved over time. The endpoint is not paginated, so each sync stores the event history the API returns for the machine at that moment.",+ "docs_url": "https://fly.io/docs/machines/api/machines-resource/",+ "columns": {+ "id": "Identifier for the event, unique within its machine.",+ "machine_id": "ID of the machine the event belongs to.",+ "app_name": "Name of the app the machine belongs to.",+ "type": "Event type (e.g. start, exit, restart, launch).",+ "status": "Machine status after the event (e.g. started, stopped).",+ "source": "What caused the event (e.g. flyd, user, monitor).",+ "timestamp": "When the event happened, in milliseconds since the Unix epoch.",+ "request": "Details of the event, such as the exit code and out-of-memory flag for an exit event.",+ },+ },+ "machine_versions": {+ "description": "Configuration version history per machine, giving the deploy and rollout timeline for each machine.",+ "docs_url": "https://fly.io/docs/machines/api/machines-resource/",+ "columns": {+ "version": "Identifier of this configuration version, unique within its machine.",+ "machine_id": "ID of the machine the version belongs to.",+ "app_name": "Name of the app the machine belongs to.",+ "user_config": "The machine configuration at this version (guest resources, image, and services). Secret-bearing fields are excluded: environment variables, secrets, inline file contents, user-defined metadata (only Fly's own platform keys are kept), and request headers on services and checks.",+ },+ },+ "volume_snapshots": {+ "description": "Snapshot history per volume, the record of which volumes have backups and how far back they reach.",+ "docs_url": "https://fly.io/docs/machines/api/volumes-resource/",+ "columns": {+ "id": "Identifier for the snapshot, unique within its volume.",+ "volume_id": "ID of the volume the snapshot was taken from.",+ "app_name": "Name of the app the volume belongs to.",+ "created_at": "Timestamp the snapshot was taken (RFC 3339).",+ "status": "Current status of the snapshot (e.g. created, pending).",+ "digest": "Content digest of the snapshot.",+ "size": "Size of the snapshot in bytes.",+ "volume_size": "Size of the source volume at the time of the snapshot, in bytes.",+ "retention_days": "Number of days the snapshot is kept before it expires.",+ },+ },}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/fly_io/fly_io.py b/products/warehouse_sources/backend/temporal/data_imports/sources/fly_io/fly_io.pyindex a9445421913b..9fa4a9011bd3 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/fly_io/fly_io.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/fly_io/fly_io.py@@ -1,4 +1,5 @@-from typing import Any+from collections.abc import Callable+from typing import Any, castfrom urllib.parse import quotefrom products.warehouse_sources.backend.temporal.data_imports.sources.common.http import make_tracked_session@@ -8,8 +9,13 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.resEndpointResource,RESTAPIConfig,rest_api_resource,+ rest_api_resources,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.config_setup import (+ make_parent_key_name,)from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.paginators import (+ BasePaginator,JSONResponseCursorPaginator,SinglePagePaginator,)@@ -102,11 +108,17 @@ def _sanitize_machine_config(config: dict[str, Any]) -> dict[str, Any]:return _strip_headers(safe)-def _sanitize_machine(row: dict[str, Any]) -> dict[str, Any]:- config = row.get("config")- if isinstance(config, dict):- return {**row, "config": _sanitize_machine_config(config)}- return row+def _sanitize_config_field(field_name: str) -> Callable[[dict[str, Any]], dict[str, Any]]:+ """Reduce the machine config a row carries under `field_name` to the safe allowlist. Machines+ carry it as `config`, machine versions as `user_config`."""++ def _mapper(row: dict[str, Any]) -> dict[str, Any]:+ config = row.get(field_name)+ if isinstance(config, dict):+ return {**row, field_name: _sanitize_machine_config(config)}+ return row++ return _mapperdef _endpoint_path(config: FlyIoEndpointConfig, org_slug: str) -> str:@@ -120,7 +132,7 @@ def _endpoint_path(config: FlyIoEndpointConfig, org_slug: str) -> str:def _endpoint_params(config: FlyIoEndpointConfig, org_slug: str) -> dict[str, Any]:params: dict[str, Any] = {}- if "{org_slug}" not in config.path:+ if config.org_slug_param:params["org_slug"] = org_slugif config.paginated:params["limit"] = _PAGE_SIZE@@ -146,6 +158,78 @@ def validate_credentials(api_token: str, org_slug: str) -> tuple[bool, str | Nonreturn False, f"Fly.io API returned an unexpected status ({status})."+def _paginator(config: FlyIoEndpointConfig) -> BasePaginator:+ return (+ JSONResponseCursorPaginator(cursor_path="next_cursor", cursor_param="cursor")+ if config.paginated+ else SinglePagePaginator()+ )+++def _top_level_endpoint(config: FlyIoEndpointConfig, org_slug: str) -> Endpoint:+ return {+ "path": _endpoint_path(config, org_slug),+ "params": _endpoint_params(config, org_slug),+ "paginator": _paginator(config),+ "data_selector": config.response_data_path,+ # Every top-level endpoint wraps its rows in an object ({"apps": [...]} etc.). A 200 body+ # that isn't that shape (a bare list, or the wrapper key gone) means the API changed — fail+ # loud rather than silently syncing zero rows, which would look like a successful-but-empty+ # sync.+ "data_selector_required": True,+ }+++def _child_row_mapper(config: FlyIoEndpointConfig) -> Callable[[dict[str, Any]], dict[str, Any]]:+ """Flatten the parent fields the fan-out injects onto each child row, then drop any secrets the+ row's own machine config carries."""+ fanout = config.fanout+ assert fanout is not None+ renames = {make_parent_key_name(fanout.parent, src): dst for src, dst in fanout.parent_fields.items()}+ sanitize = _sanitize_config_field(config.secret_config_field) if config.secret_config_field else None++ def _mapper(row: dict[str, Any]) -> dict[str, Any]:+ for prefixed_key, target_key in renames.items():+ if prefixed_key in row:+ row[target_key] = row.pop(prefixed_key)+ return sanitize(row) if sanitize else row++ return _mapper+++def _fanout_resources(config: FlyIoEndpointConfig, org_slug: str) -> list[EndpointResource]:+ """The parent listing plus the child endpoint that resolves its path from each parent row. Only+ the child is synced; the parent is walked to drive it."""+ fanout = config.fanout+ assert fanout is not None+ parent_config = FLY_IO_ENDPOINTS[fanout.parent]++ parent_resource: EndpointResource = {+ "name": fanout.parent,+ "endpoint": _top_level_endpoint(parent_config, org_slug),+ }+ child_resource: EndpointResource = {+ "name": config.name,+ "endpoint": {+ "path": config.path,+ "params": {+ **{+ placeholder: {"type": "resolve", "resource": fanout.parent, "field": parent_field}+ for placeholder, parent_field in fanout.path_params.items()+ },+ **fanout.child_params,+ },+ "paginator": SinglePagePaginator(),+ # These endpoints return a bare array, so no data selector applies. It stays unrequired+ # because a Go API can serialize an empty collection as `null` rather than `[]`, and a+ # required list body would turn a machine with no events into a failed sync.+ },+ "include_from_parent": list(fanout.parent_fields),+ "data_map": _child_row_mapper(config),+ }+ return [parent_resource, child_resource]++def fly_io_source(api_token: str,endpoint: str,@@ -154,18 +238,14 @@ def fly_io_source(job_id: str,) -> SourceResponse:"""Build the rest_source resource for a Fly.io stream. The org machines/volumes endpoints- paginate with an opaque `next_cursor`; the apps endpoint returns everything in one response.- Rows are yielded in the shape the API returns them, except the machines stream, whose rows can- embed deployment secrets: those are reduced to a safe operational allowlist and the stream opts- out of HTTP sample capture, so secrets reach neither the warehouse nor the sample pipeline."""+ paginate with an opaque `next_cursor`; every other endpoint returns everything in one response.+ Per-machine and per-volume endpoints only exist under an app, so they fan out over their org-wide+ parent listing and carry the parent's app name and id onto each row. Rows are yielded in the+ shape the API returns them, except where they embed a machine config: those are reduced to a safe+ operational allowlist, and any stream whose traffic can carry secrets opts out of HTTP sample+ capture, so secrets reach neither the warehouse nor the sample pipeline."""config = FLY_IO_ENDPOINTS[endpoint]- paginator = (- JSONResponseCursorPaginator(cursor_path="next_cursor", cursor_param="cursor")- if config.paginated- else SinglePagePaginator()- )-client_config: ClientConfig = {"base_url": FLY_IO_BASE_URL,# Auth (Bearer) is supplied via the framework auth config so its value is redacted from@@ -179,24 +259,18 @@ def fly_io_source(# still masked in whatever remains logged.client_config["session"] = make_tracked_session(capture=False, redact_values=(api_token,))- endpoint_config: Endpoint = {- "path": _endpoint_path(config, org_slug),- "params": _endpoint_params(config, org_slug),- "paginator": paginator,- "data_selector": config.response_data_path,- # Every list endpoint wraps its rows in an object ({"apps": [...]} etc.). A 200 body that- # isn't that shape (a bare list, or the wrapper key gone) means the API changed — fail loud- # rather than silently syncing zero rows, which would look like a successful-but-empty sync.- "data_selector_required": True,- }-- resource_config: EndpointResource = {"name": endpoint, "endpoint": endpoint_config}- if config.redact_secrets:- resource_config["data_map"] = _sanitize_machine-- rest_config: RESTAPIConfig = {"client": client_config, "resources": [resource_config]}-- resource = rest_api_resource(rest_config, team_id, job_id, None)+ if config.fanout:+ rest_config: RESTAPIConfig = {+ "client": client_config,+ "resource_defaults": {},+ "resources": cast("list[str | EndpointResource]", _fanout_resources(config, org_slug)),+ }+ resource = next(r for r in rest_api_resources(rest_config, team_id, job_id, None) if r.name == endpoint)+ else:+ resource_config: EndpointResource = {"name": endpoint, "endpoint": _top_level_endpoint(config, org_slug)}+ if config.secret_config_field:+ resource_config["data_map"] = _sanitize_config_field(config.secret_config_field)+ resource = rest_api_resource({"client": client_config, "resources": [resource_config]}, team_id, job_id, None)return SourceResponse(name=endpoint,diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/fly_io/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/fly_io/settings.pyindex 3368b14555cf..1a0f70799c18 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/fly_io/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/fly_io/settings.py@@ -1,29 +1,53 @@-from dataclasses import dataclass, field-from typing import Optional+from dataclasses import field+from typing import Any, Optional++from posthog.dataclasses import frozenfrom products.warehouse_sources.backend.types import IncrementalField-@dataclass+@frozen+class FlyIoFanoutConfig:+ # Schema name of the endpoint whose rows drive this one.+ parent: str+ # Child path placeholder -> the parent row field bound to it.+ path_params: dict[str, str]+ # Parent row field -> the column each child row carries it under.+ parent_fields: dict[str, str]+ # Extra query params for the child request.+ child_params: dict[str, Any] = field(default_factory=dict)+++@frozenclass FlyIoEndpointConfig:name: str# Path template relative to the API base. `{org_slug}` is substituted with the configured# organization for the org-scoped endpoints; the apps endpoint takes org_slug as a query- # param instead (see `_endpoint_path`/`_endpoint_params` in fly_io.py).+ # param instead (see `_endpoint_path`/`_endpoint_params` in fly_io.py). A fan-out child's+ # placeholders are bound per parent row instead (see `fanout`).path: str# Body key the list of rows lives under (e.g. {"apps": [...]}, {"machines": [...]}).- response_data_path: str+ # None when the endpoint returns a bare array.+ response_data_path: Optional[str]primary_keys: list[str] = field(default_factory=lambda: ["id"])# Stable creation timestamp used for datetime partitioning. None disables partitioning —# Fly.io app objects carry no timestamp at all.partition_key: Optional[str] = None# True when the endpoint returns a `next_cursor` and accepts a `cursor` query param.paginated: bool = False- # True when rows can embed deployment secrets (a machine's `config` carries env vars,- # per-process env, and inline file contents). Such a stream is reduced to a safe- # operational allowlist before it's yielded and excluded from HTTP sample capture, so- # secrets never reach the warehouse or the sample-capture pipeline.+ # True when the endpoint scopes to an organization through an `org_slug` query param rather+ # than through the path. The platform-wide endpoints take neither.+ org_slug_param: bool = False+ # True when the stream's HTTP traffic can carry deployment secrets, either in its own rows+ # or in its fan-out parent's. Such a stream is excluded from HTTP sample capture so secrets+ # never reach the sample-capture pipeline.redact_secrets: bool = False+ # Row key holding a machine config (env vars, per-process env, inline file contents). Such a+ # field is reduced to a safe operational allowlist before the row is yielded, so secrets+ # never reach the warehouse.+ secret_config_field: Optional[str] = None+ # Set when the endpoint only exists per parent resource and has to be fanned out.+ fanout: Optional[FlyIoFanoutConfig] = None# Fly.io streams. We use the org-level aggregate endpoints for machines and volumes@@ -39,6 +63,7 @@ FLY_IO_ENDPOINTS: dict[str, FlyIoEndpointConfig] = {# App objects have no created_at/updated_at, so datetime partitioning isn't possible.partition_key=None,paginated=False,+ org_slug_param=True,),"machines": FlyIoEndpointConfig(name="machines",@@ -47,6 +72,7 @@ FLY_IO_ENDPOINTS: dict[str, FlyIoEndpointConfig] = {partition_key="created_at",paginated=True,redact_secrets=True,+ secret_config_field="config",),"volumes": FlyIoEndpointConfig(name="volumes",@@ -55,6 +81,67 @@ FLY_IO_ENDPOINTS: dict[str, FlyIoEndpointConfig] = {partition_key="created_at",paginated=True,),+ "regions": FlyIoEndpointConfig(+ name="regions",+ path="/platform/regions",+ response_data_path="regions",+ primary_keys=["code"],+ # Regions are a static lookup with no timestamps.+ partition_key=None,+ paginated=False,+ ),+ "machine_events": FlyIoEndpointConfig(+ name="machine_events",+ path="/apps/{app_name}/machines/{machine_id}/events",+ response_data_path=None,+ # Neither machine nor event ids are documented as globally unique across apps.+ primary_keys=["app_name", "machine_id", "id"],+ # The only time field is `timestamp`, epoch milliseconds rather than the RFC 3339 string+ # datetime partitioning needs.+ partition_key=None,+ paginated=False,+ # Event rows carry no secrets, but the machines listing that drives the fan-out does.+ redact_secrets=True,+ fanout=FlyIoFanoutConfig(+ parent="machines",+ path_params={"app_name": "app_name", "machine_id": "id"},+ parent_fields={"app_name": "app_name", "id": "machine_id"},+ # The endpoint returns 20 events when `limit` is omitted and caps at 50. It is not+ # paginated, so 50 is the most history a sync can see for a machine.+ child_params={"limit": 50},+ ),+ ),+ "machine_versions": FlyIoEndpointConfig(+ name="machine_versions",+ path="/apps/{app_name}/machines/{machine_id}/versions",+ response_data_path=None,+ # A version row carries no id; its app, machine, and version identify the config.+ primary_keys=["app_name", "machine_id", "version"],+ # Version rows carry no timestamp.+ partition_key=None,+ paginated=False,+ redact_secrets=True,+ secret_config_field="user_config",+ fanout=FlyIoFanoutConfig(+ parent="machines",+ path_params={"app_name": "app_name", "machine_id": "id"},+ parent_fields={"app_name": "app_name", "id": "machine_id"},+ ),+ ),+ "volume_snapshots": FlyIoEndpointConfig(+ name="volume_snapshots",+ path="/apps/{app_name}/volumes/{volume_id}/snapshots",+ response_data_path=None,+ # Neither volume nor snapshot ids are documented as globally unique across apps.+ primary_keys=["app_name", "volume_id", "id"],+ partition_key="created_at",+ paginated=False,+ fanout=FlyIoFanoutConfig(+ parent="volumes",+ path_params={"app_name": "app_name", "volume_id": "id"},+ parent_fields={"app_name": "app_name", "id": "volume_id"},+ ),+ ),}ENDPOINTS = tuple(FLY_IO_ENDPOINTS.keys())diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/fly_io/tests/test_fly_io.py b/products/warehouse_sources/backend/temporal/data_imports/sources/fly_io/tests/test_fly_io.pyindex b57ec49bb1a9..aea1fde06a10 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/fly_io/tests/test_fly_io.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/fly_io/tests/test_fly_io.py@@ -8,7 +8,7 @@ from parameterized import parameterizedfrom requests import Responsefrom products.warehouse_sources.backend.temporal.data_imports.sources.fly_io.fly_io import (- _sanitize_machine,+ _sanitize_config_field,fly_io_source,validate_credentials,)@@ -22,7 +22,7 @@ FLY_IO_SESSION_PATCH = ()-def _response(body: dict[str, Any], status: int = 200) -> Response:+def _response(body: Any, status: int = 200) -> Response:resp = Response()resp.status_code = statusresp._content = json.dumps(body).encode()@@ -97,6 +97,18 @@ class TestPaginationAndUrls:assert snaps[0]["url"] == f"https://api.machines.dev/v1/orgs/ac%2Fme/{endpoint}"+ @mock.patch(CLIENT_SESSION_PATCH)+ def test_regions_is_a_platform_wide_lookup(self, MockClientSession) -> None:+ # Regions are not org-scoped, so the org slug must not reach the request at all.+ session = MockClientSession.return_value+ snaps = _wire(session, [_response({"nearest": "lhr", "regions": [{"code": "iad"}, {"code": "lhr"}]})])++ rows = _rows(fly_io_source("tok", "regions", "acme", team_id=1, job_id="j"))++ assert snaps[0]["url"] == "https://api.machines.dev/v1/platform/regions"+ assert snaps[0]["params"] == {}+ assert [r["code"] for r in rows] == ["iad", "lhr"]+@mock.patch(CLIENT_SESSION_PATCH)def test_apps_is_single_request_and_ignores_cursor(self, MockClientSession) -> None:# The apps endpoint isn't paginated; a stray next_cursor must not trigger a second request@@ -143,12 +155,160 @@ class TestPaginationAndUrls:def test_unexpected_response_shape_raises(self, MockClientSession) -> None:# A bare list where an object wrapper is expected must fail loudly, not silently sync zero rows.session = MockClientSession.return_value- _wire(session, [_response([{"id": "x"}])]) # type: ignore[arg-type]+ _wire(session, [_response([{"id": "x"}])])with pytest.raises(ValueError):_rows(fly_io_source("tok", "apps", "acme", team_id=1, job_id="j"))+class TestFanout:+ @parameterized.expand(+ [+ (+ "machine_events",+ "machines",+ {"id": "m1", "app_name": "app1"},+ [{"id": "e1", "type": "start"}],+ "https://api.machines.dev/v1/apps/app1/machines/m1/events",+ {"machine_id": "m1", "app_name": "app1"},+ ),+ (+ "machine_versions",+ "machines",+ {"id": "m1", "app_name": "app1"},+ [{"version": "v1", "user_config": {"image": "app"}}],+ "https://api.machines.dev/v1/apps/app1/machines/m1/versions",+ {"machine_id": "m1", "app_name": "app1"},+ ),+ (+ "volume_snapshots",+ "volumes",+ {"id": "vol1", "app_name": "app1"},+ [{"id": "s1", "created_at": "2026-01-01T00:00:00Z"}],+ "https://api.machines.dev/v1/apps/app1/volumes/vol1/snapshots",+ {"volume_id": "vol1", "app_name": "app1"},+ ),+ ]+ )+ @mock.patch(FLY_IO_SESSION_PATCH)+ @mock.patch(CLIENT_SESSION_PATCH)+ def test_child_path_binds_to_its_parent_row_and_carries_its_columns(+ self,+ endpoint: str,+ parent: str,+ parent_row: dict[str, Any],+ child_rows: list[dict[str, Any]],+ expected_child_url: str,+ expected_parent_columns: dict[str, str],+ MockClientSession,+ MockFlyIoSession,+ ) -> None:+ # The child path needs BOTH the app name and the resource id from the same parent row, and+ # each row has to carry them as flat columns — the composite primary key is built from them.+ session = MockClientSession.return_value+ MockFlyIoSession.return_value = session+ snaps = _wire(session, [_response({parent: [parent_row], "next_cursor": None}), _response(child_rows)])++ rows = _rows(fly_io_source("tok", endpoint, "acme", team_id=1, job_id="j"))++ assert snaps[1]["url"] == expected_child_url+ assert len(rows) == len(child_rows)+ for row in rows:+ for column, value in expected_parent_columns.items():+ assert row[column] == value+ # The raw `_<parent>_<field>` keys the fan-out injects must not survive into the table.+ assert not any(key.startswith(f"_{parent}_") for key in row)++ @mock.patch(FLY_IO_SESSION_PATCH)+ @mock.patch(CLIENT_SESSION_PATCH)+ def test_child_is_requested_once_per_parent_row(self, MockClientSession, MockFlyIoSession) -> None:+ # A fan-out that walks only the first parent, or re-walks one parent, silently changes what+ # the table contains — assert one child request per parent across a paginated parent listing.+ session = MockClientSession.return_value+ MockFlyIoSession.return_value = session+ snaps = _wire(+ session,+ [+ _response({"machines": [{"id": "m1", "app_name": "app1"}], "next_cursor": "c2"}),+ _response([{"id": "e1"}]),+ _response({"machines": [{"id": "m2", "app_name": "app2"}], "next_cursor": None}),+ _response([{"id": "e2"}]),+ ],+ )++ rows = _rows(fly_io_source("tok", "machine_events", "acme", team_id=1, job_id="j"))++ assert [r["machine_id"] for r in rows] == ["m1", "m2"]+ assert [s["url"] for s in snaps if "/events" in s["url"]] == [+ "https://api.machines.dev/v1/apps/app1/machines/m1/events",+ "https://api.machines.dev/v1/apps/app2/machines/m2/events",+ ]++ @mock.patch(FLY_IO_SESSION_PATCH)+ @mock.patch(CLIENT_SESSION_PATCH)+ def test_machine_events_asks_for_the_largest_window(self, MockClientSession, MockFlyIoSession) -> None:+ # The endpoint returns 20 events when `limit` is omitted and caps at 50, and it is not+ # paginated, so omitting the param silently drops the older events of a busy machine.+ session = MockClientSession.return_value+ MockFlyIoSession.return_value = session+ snaps = _wire(+ session,+ [_response({"machines": [{"id": "m1", "app_name": "app1"}], "next_cursor": None}), _response([])],+ )++ _rows(fly_io_source("tok", "machine_events", "acme", team_id=1, job_id="j"))++ assert snaps[1]["params"]["limit"] == 50++ @mock.patch(FLY_IO_SESSION_PATCH)+ @mock.patch(CLIENT_SESSION_PATCH)+ def test_null_child_body_yields_no_rows(self, MockClientSession, MockFlyIoSession) -> None:+ # Fly.io serializes an empty collection as `null` rather than `[]`; a machine with no events+ # must be an empty child, not a failed sync.+ session = MockClientSession.return_value+ MockFlyIoSession.return_value = session+ _wire(+ session, [_response({"machines": [{"id": "m1", "app_name": "app1"}], "next_cursor": None}), _response(None)]+ )++ assert _rows(fly_io_source("tok", "machine_events", "acme", team_id=1, job_id="j")) == []++ @mock.patch(FLY_IO_SESSION_PATCH)+ @mock.patch(CLIENT_SESSION_PATCH)+ def test_machine_versions_sanitizes_its_user_config(self, MockClientSession, MockFlyIoSession) -> None:+ # A version row carries the whole machine config under `user_config`, so it needs the same+ # redaction as the machines stream — otherwise deploy secrets land in the warehouse.+ session = MockClientSession.return_value+ MockFlyIoSession.return_value = session+ _wire(+ session,+ [+ _response({"machines": [{"id": "m1", "app_name": "app1"}], "next_cursor": None}),+ _response([{"version": "v1", "user_config": {"image": "app", "env": {"SECRET": "x"}}}]),+ ],+ )++ rows = _rows(fly_io_source("tok", "machine_versions", "acme", team_id=1, job_id="j"))++ assert rows == [{"version": "v1", "user_config": {"image": "app"}, "machine_id": "m1", "app_name": "app1"}]++ @parameterized.expand([("machine_events",), ("machine_versions",)])+ @mock.patch(FLY_IO_SESSION_PATCH)+ @mock.patch(CLIENT_SESSION_PATCH)+ def test_machine_parented_streams_disable_sample_capture(+ self, endpoint: str, MockClientSession, MockFlyIoSession+ ) -> None:+ # The machines listing that drives these fan-outs returns machine configs, so their traffic+ # can carry secrets even where the child rows cannot.+ session = MockClientSession.return_value+ MockFlyIoSession.return_value = session+ _wire(session, [_response({"machines": [], "next_cursor": None})])++ _rows(fly_io_source("tok", endpoint, "acme", team_id=1, job_id="j"))++ MockFlyIoSession.assert_called_once_with(capture=False, redact_values=("tok",))++class TestSampleCaptureAndRedaction:@mock.patch(FLY_IO_SESSION_PATCH)@mock.patch(CLIENT_SESSION_PATCH)@@ -194,6 +354,9 @@ class TestSampleCaptureAndRedaction:MockFlyIoSession.assert_not_called()+_sanitize_machine = _sanitize_config_field("config")++class TestMachineSecretRedaction:def test_sanitize_strips_secret_bearing_config_fields(self) -> None:# env, files (inline file contents), and secrets would land deployment credentials in the@@ -302,6 +465,7 @@ class TestFlyIoSourceResponse:[("machines", "created_at"),("volumes", "created_at"),+ ("volume_snapshots", "created_at"),])@mock.patch(FLY_IO_SESSION_PATCH)@@ -313,12 +477,16 @@ class TestFlyIoSourceResponse:response = fly_io_source("tok", endpoint, "acme", team_id=1, job_id="j")assert response.partition_mode == "datetime"assert response.partition_keys == [partition_key]- assert response.primary_keys == ["id"]+ @parameterized.expand([("apps",), ("regions",), ("machine_events",), ("machine_versions",)])+ @mock.patch(FLY_IO_SESSION_PATCH)@mock.patch(CLIENT_SESSION_PATCH)- def test_apps_has_no_partitioning(self, MockClientSession) -> None:- # App objects carry no timestamp, so partitioning on a nonexistent column would break the sync.- response = fly_io_source("tok", "apps", "acme", team_id=1, job_id="j")+ def test_timestampless_endpoints_have_no_partitioning(+ self, endpoint: str, MockClientSession, MockFlyIoSession+ ) -> None:+ # These rows carry no RFC 3339 timestamp (machine events only carry epoch milliseconds), so+ # partitioning on one would break the sync.+ MockFlyIoSession.return_value = MockClientSession.return_value+ response = fly_io_source("tok", endpoint, "acme", team_id=1, job_id="j")assert response.partition_mode is Noneassert response.partition_keys is None- assert response.primary_keys == ["id"]diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/fly_io/tests/test_fly_io_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/fly_io/tests/test_fly_io_source.pyindex ca04e36a8777..0de9ad008716 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/fly_io/tests/test_fly_io_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/fly_io/tests/test_fly_io_source.py@@ -1,7 +1,7 @@from parameterized import parameterizedfrom products.warehouse_sources.backend.facade.source_config import SourceFieldInputConfig, SourceFieldInputConfigType-from products.warehouse_sources.backend.temporal.data_imports.sources.fly_io.settings import ENDPOINTS+from products.warehouse_sources.backend.temporal.data_imports.sources.fly_io.settings import ENDPOINTS, FLY_IO_ENDPOINTSfrom products.warehouse_sources.backend.temporal.data_imports.sources.fly_io.source import FlyIoSourcefrom products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs.flyio import FlyIoSourceConfig@@ -30,12 +30,22 @@ class TestSourceConfig:class TestGetSchemas:def test_returns_all_endpoints_full_refresh(self) -> None:schemas = {s.name: s for s in FlyIoSource().get_schemas(_config(), team_id=1)}- assert set(schemas) == set(ENDPOINTS) == {"apps", "machines", "volumes"}+ assert set(schemas) == set(ENDPOINTS)# No verified server-side time filter, so every stream is full refresh only.for schema in schemas.values():assert schema.supports_incremental is Falseassert schema.supports_append is False- assert schema.detected_primary_keys == ["id"]++ @parameterized.expand(+ [("machine_events", "machine_id"), ("machine_versions", "machine_id"), ("volume_snapshots", "volume_id")]+ )+ def test_fanout_children_key_on_their_app_and_parent(self, endpoint: str, parent_column: str) -> None:+ schema = FlyIoSource().get_schemas(_config(), team_id=1, names=[endpoint])[0]+ assert schema.detected_primary_keys is not None+ assert {"app_name", parent_column} <= set(schema.detected_primary_keys)+ assert {"app_name", parent_column} <= set(+ FLY_IO_ENDPOINTS[endpoint].fanout.parent_fields.values() # type: ignore[union-attr]+ )def test_names_filter(self) -> None:schemas = FlyIoSource().get_schemas(_config(), team_id=1, names=["machines"])