Skip to content

: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.

fix(custom): reject incremental config in resource_defaults (#112267)

Tom Owers1bf7ed15e82f
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/custom/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/custom/source.py
index 356b1cd4daea..e38625f93ac9 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/custom/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/custom/source.py
@@ -379,6 +379,16 @@ def _validate_incremental_configs(manifest: dict[str, Any]) -> None:
from ``setup_incremental_object``, and an unsupported key as a ``TypeError`` from the
engine's ``Incremental(**config)`` constructor.
"""
+ resource_defaults = manifest.get("resource_defaults")
+ default_endpoint = resource_defaults.get("endpoint") if isinstance(resource_defaults, dict) else None
+ if isinstance(default_endpoint, dict) and _has_incremental_config(default_endpoint):
+ # The engine merges defaults into every resource, so a default cursor would bypass the
+ # per-resource handling: preview stripping, cursor typing, and keeping fan-out parents full-scan.
+ raise ManifestValidationError(
+ "resource_defaults.endpoint can't declare incremental config. "
+ "Set endpoint.incremental on each resource that syncs incrementally instead"
+ )
+
for resource in manifest.get("resources") or []:
if not isinstance(resource, dict):
continue
@@ -407,6 +417,15 @@ def _validate_incremental_configs(manifest: dict[str, Any]) -> None:
)
+def _has_incremental_config(endpoint: dict[str, Any]) -> bool:
+ if endpoint.get("incremental") is not None:
+ return True
+ params = endpoint.get("params")
+ return isinstance(params, dict) and any(
+ isinstance(value, dict) and value.get("type") == "incremental" for value in params.values()
+ )
+
+
def _validate_paginator_configs(manifest: dict[str, Any]) -> None:
"""Reject paginator config keys that would deterministically crash at sync time.
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/custom/test_custom_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/custom/test_custom_source.py
index 31bf26b8245a..ebb48a6ef77b 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/custom/test_custom_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/custom/test_custom_source.py
@@ -2629,6 +2629,34 @@ class TestCustomSourceIncrementalUnsupportedKeys(SimpleTestCase):
assert ok is False
assert err is not None and "upstream_row_order" in err and "'users'" in err
+ @parameterized.expand(
+ [
+ (
+ "endpoint_incremental",
+ {"incremental": {"cursor_path": "updated_at", "start_param": "since", "cursor_type": "integer"}},
+ ),
+ (
+ "params_incremental",
+ {"params": {"since": {"type": "incremental", "cursor_path": "updated_at", "cursor_type": "integer"}}},
+ ),
+ ]
+ )
+ @patch("products.warehouse_sources.backend.temporal.data_imports.sources.custom.source.rest_api_resources")
+ def test_incremental_in_resource_defaults_rejected(self, _name, default_endpoint, mock_resources):
+ manifest = _minimal_manifest()
+ manifest["resource_defaults"] = {"endpoint": default_endpoint}
+ source = CustomSource()
+ config = CustomSourceConfig(manifest_json=json.dumps(manifest), auth_token="abc")
+
+ with self.assertRaises(ManifestValidationError) as ctx:
+ source.preview_resource(config, team_id=999, resource_name="users")
+ assert "resource_defaults" in str(ctx.exception)
+ mock_resources.assert_not_called()
+
+ ok, err = source.validate_credentials(config, team_id=999)
+ assert ok is False
+ assert err is not None and "resource_defaults" in err
+
class TestCustomSourcePaginatorUnsupportedKeys(SimpleTestCase):
def _manifest(self) -> dict:
diff --git a/products/warehouse_sources/skills/setting-up-a-custom-rest-source/references/manifest-reference.md b/products/warehouse_sources/skills/setting-up-a-custom-rest-source/references/manifest-reference.md
index 5f00d9a2c16e..943a1958a5d2 100644
--- a/products/warehouse_sources/skills/setting-up-a-custom-rest-source/references/manifest-reference.md
+++ b/products/warehouse_sources/skills/setting-up-a-custom-rest-source/references/manifest-reference.md
@@ -28,7 +28,7 @@ real engine behavior. Only the fields the engine reads are documented here; unkn
- **`client.headers`** (optional) — static headers sent on every request.
- **`client.paginator`** (optional) — a default paginator for all resources; override per resource on the endpoint.
- **`resource_defaults.endpoint`** (optional) — endpoint fields merged into every resource (e.g. a shared paginator or
- `data_selector`).
+ `data_selector`). Incremental config isn't allowed here; set `endpoint.incremental` on each resource instead.
- **`resources`** (required, 1–50) — one entry per table you want to import. Each has a unique `name` (becomes the
table name) and an `endpoint`.