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(data-imports): read Omnisend campaigns from the singular key (#78734)

Tom Owers45f83f425ada
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/omnisend/api_inventory.md b/products/warehouse_sources/backend/temporal/data_imports/sources/omnisend/api_inventory.md
index d83095ed4a4f..b3953490ff5d 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/omnisend/api_inventory.md
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/omnisend/api_inventory.md
@@ -19,16 +19,16 @@ changing endpoint behavior — see the `implementing-warehouse-sources` skill.
| Schema | Path | Response array key | Primary key | Partition (stable) |
| ---------- | ------------- | ------------------ | ------------ | ------------------ |
| contacts | `/contacts` | `contacts` | `contactID` | `createdAt` |
-| campaigns | `/campaigns` | `campaigns` | `campaignID` | `createdAt` |
+| campaigns | `/campaigns` | `campaign` | `campaignID` | `createdAt` |
| carts | `/carts` | `carts` | `cartID` | `createdAt` |
| orders | `/orders` | `orders` | `orderID` | `createdAt` |
| products | `/products` | `products` | `productID` | `createdAt` |
| categories | `/categories` | `categories` | `categoryID` | — |
Endpoint existence confirmed against the live API (all return non-404 without a key).
-Primary-key / response-key names follow Omnisend's consistent `<resource>` /
-`<resource>ID` v3 convention (the create-contact response returns `contactID`); exact
-shapes of the list responses were not re-verified with a live key.
+Primary keys follow Omnisend's `<resource>ID` v3 convention. Response array keys follow
+the plural `<resource>` convention **except `/campaigns`, which nests rows under the
+singular `campaign`** — confirmed against the live response body.
## Sync mode
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/omnisend/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/omnisend/settings.py
index 2e7c2864ea61..b93d1c14ea85 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/omnisend/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/omnisend/settings.py
@@ -29,7 +29,9 @@ OMNISEND_ENDPOINTS: dict[str, OmnisendEndpointConfig] = {
"campaigns": OmnisendEndpointConfig(
name="campaigns",
path="/campaigns",
- data_key="campaigns",
+ # `/campaigns` is the one v3 list endpoint that nests its rows under the singular
+ # `campaign` key; every other resource uses the plural `<resource>` convention.
+ data_key="campaign",
primary_key="campaignID",
partition_key="createdAt",
),
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/omnisend/tests/test_omnisend.py b/products/warehouse_sources/backend/temporal/data_imports/sources/omnisend/tests/test_omnisend.py
index 16d051d4785f..f26e27079360 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/omnisend/tests/test_omnisend.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/omnisend/tests/test_omnisend.py
@@ -132,6 +132,18 @@ class TestPagination:
assert rows == [{"contactID": "1"}]
manager.save_state.assert_not_called()
+ @mock.patch(CLIENT_SESSION_PATCH)
+ def test_campaigns_rows_read_from_singular_key(self, MockSession) -> None:
+ # Omnisend's `/campaigns` nests rows under the singular `campaign`, unlike every other
+ # endpoint's plural key. Extraction must follow that, or the sync fails loud on 0 rows.
+ session = MockSession.return_value
+ _wire(session, [_page([{"campaignID": "c1"}], next_url=None, key="campaign")])
+
+ manager = _make_manager()
+ rows = _rows(omnisend_source("test-key", "campaigns", team_id=1, job_id="j", resumable_source_manager=manager))
+
+ assert rows == [{"campaignID": "c1"}]
+
@mock.patch(CLIENT_SESSION_PATCH)
def test_empty_page_yields_nothing(self, MockSession) -> None:
session = MockSession.return_value