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 a non-object client.headers in the manifest (#115311)

Tom Owers62b3f0522514
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 3690a75ba01d..38b2b592aec6 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
@@ -199,6 +199,9 @@ def _without_retry_limit_overrides(client: dict[str, Any]) -> dict[str, Any]:
class _ManifestClient(BaseModel):
base_url: str = Field(min_length=1)
auth: _ManifestAuth | None = None
+ # Modelled only so a non-object `headers` is rejected here. The probe and the REST
+ # engine both spread it into a dict, which raises a TypeError the sync would retry.
+ headers: dict[str, Any] | None = None
class _ManifestEndpoint(BaseModel):
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 1e7bbd2fc6c2..361a6c3fa108 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
@@ -200,13 +200,20 @@ class TestValidateManifest(SimpleTestCase):
}
validate_manifest(manifest)
- @parameterized.expand([("json", ["not", "an", "object"]), ("params", ["nope"])])
- def test_rejects_non_object_params_or_json(self, field, value):
+ @parameterized.expand(
+ [
+ ("json", ["not", "an", "object"], "resources[0].endpoint.json"),
+ ("params", ["nope"], "resources[0].endpoint.params"),
+ ("headers", 5, "client.headers"),
+ ]
+ )
+ def test_rejects_non_object_params_json_or_headers(self, field, value, expected_location):
manifest = _minimal_manifest()
- manifest["resources"][0]["endpoint"][field] = value
+ container = manifest["client"] if field == "headers" else manifest["resources"][0]["endpoint"]
+ container[field] = value
with self.assertRaises(ManifestValidationError) as ctx:
validate_manifest(manifest)
- assert field in str(ctx.exception)
+ assert expected_location in str(ctx.exception)
@parameterized.expand(
[