Repository navigation
feat(hs_audience): hubspot audience list membership destination - #5638
Conversation
🔒 Scanned for secrets using gitleaks 8.28.0
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #5638 +/- ##
===========================================
+ Coverage 92.12% 92.15% +0.03%
===========================================
Files 713 719 +6
Lines 39600 39967 +367
Branches 9205 9281 +76
===========================================
+ Hits 36481 36833 +352
- Misses 2934 2949 +15
Partials 185 185 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
🔒 Scanned for secrets using gitleaks 8.28.0
🔒 Scanned for secrets using gitleaks 8.28.0
am6010
left a comment
There was a problem hiding this comment.
Reviewed against the merged spec (rudder-specs#204). Solid overall:
- The token never reaches router output, errors, logs or stats.
- The
network.jschange only affectsHS_AUDIENCE. - Add and remove are split at 1000 ids, and each row uses its own list id.
- The add/remove conflict guard works.
- Each job gets its own verdict, including duplicate ids.
- The 207 lookup is matched correctly after case and whitespace normalization.
Ran on e3b23a3 with Node 22:
- hs_audience unit tests,
network.test.jsandfeatures.test.ts: 139 passed. test:ts -- component --destination=hs_audience: 9 passed.eslint,prettier --checkandtsc --noEmit: clean.
Two inline comments, one high and one medium. Also:
- Stale or merged record ids: I found no evidence that add-and-remove returns a surviving id after a merge. If it ever does,
missingIdsfails the whole batch closed, because any added or removed id that wasn't sent retries every job. The spec already lists this as a pending live check, so it's worth covering in the live run before GA. - Rollout: the router default
noOfJobsToBatchInAWorkeris 20 (10 on hosted US). Until rudderstack-operator#1775 lands, batches are about 50× smaller, which means many more lookup and membership calls. That likely explains the slowness in local testing. - Nits:
network.jshard-codes'HS_AUDIENCE'in the shared adapter; a statTags flag would be cleaner. Also, the comment says payload logs would store the bearer token, butrequestLogdoesn't log headers, so it's really the emails.- A missing token or list id is thrown as
InstrumentationError, whereConfigurationErrorwould give the righterrorType. - A 408 aborts as "rejected"; it is arguably retryable.
🔒 Scanned for secrets using gitleaks 8.28.0
lvrach
left a comment
There was a problem hiding this comment.
Commenting, no blocker. The verdict mapping is careful: every job gets exactly one verdict, the 1,000-id split never drops or doubles a job, and the token stays out of errors, logs and stats. I ran the hs_audience unit tests (99) and the component tests (11) on 5c4d09b; all pass. Two points before GA, one of them carried over from the earlier review.
[minor] Confirm the real no-op body before GA. {} now succeeds, but an empty 200 still retries every job. The proxy hands the handler '' for an empty body (networkUtils.js:163, data || ''), missingIds('') returns null, and delivery.test.ts pins that to 500. In steady state, update rows re-add current members, so if HubSpot answers those with an empty body, each batch retries and then aborts while HubSpot already holds the right state. The earlier evidence is about memberships/add, not add-and-remove, so the real shape is still open. HubSpot's spec documents only a 200 whose body carries recordIdsMissing, recordIdsRemoved and recordsIdsAdded, and no 204 or empty body. An empty 2xx therefore cannot hide a failed add. Can you run the new live no-op steps and attach the captured body? If it is empty, treat a 2xx '' the same as {}.
[minor] One unparseable secondary email now fails its whole lookup chunk. This path is new in 8f1edcc. claimResult returns false when any hs_additional_emails entry fails validator.isEmail, so all 100 emails in the chunk get LOOKUP_UNCORRELATED on every retry. Example: a contact with hs_additional_emails = "old@legacy_corp.com". validator.isEmail rejects the underscore domain (I checked), and HubSpot's own validation is looser. Skipping an address that fails validation is safe, because it can never equal a requested email, which passed the same validator. Keep the conflict check.
Optional
- [suggestion] Transport errors outside the five mapped codes (EPIPE, ENOTFOUND) become a synthetic 400 in
networkUtils.js, anddelivery.ts:209then aborts the batch as "HubSpot membership update was rejected", though HubSpot never saw the request. The lookup path already guards against this, and delivery could do the same. - [suggestion] After a 429, 401 or 403 on one lookup chunk, the loop still sends the remaining chunks (
lookup.ts:290-301). Stopping there and giving the rest the same error saves calls when HubSpot is already throttling. - [suggestion] Two cases still fail a whole chunk of 100, not one email: a 207 with a per-input error other than
OBJECT_NOT_FOUND, and two contacts that claim the same email. Degrading per email would contain both. - [suggestion]
numErrors !== errors.lengthrejects the chunk (lookup.ts:127-132). HubSpot groups missing ids into one error entry (context.ids), and the docs definenumErrorsonly as "the number of errors encountered". If it counts ids, any chunk with two or more unknown emails fails. The only live-shaped fixture has one miss. The live run could include two unknown emails to settle it. - [suggestion]
config.ts:45-47callsINVALID_OBJECT_TYPE_FOR_LIST"HubSpot's published ineligible-list signal". It is not in HubSpot's docs or OpenAPI spec. Cite the capture, or say "observed". - [suggestion] The HubSpot reply mocks are hand-typed. I validated them against HubSpot's pinned Lists v3 and Contacts v3 specs: every field the code reads matches, but 8 of 11 mocks miss fields the spec requires (
router/network.ts:14,lookup.test.ts:20,106,dataDelivery/network.ts:94,98).live.tsalready captures real bodies. Committing a recorded 200, a 207OBJECT_NOT_FOUNDand a no-op reply would tie the tests to HubSpot. - [suggestion] HubSpot returns 477 while a portal migrates between data-hosting locations, with
Retry-Afterof up to 24 hours (docs). Here 477 falls intoclientFailureand aborts every job as "rejected" (delivery.ts:209), andlookup.ts:202aborts the row. Aborted rows come back as failed keys on the next run, so nothing is lost for good. Retrying 477 is still the right verdict. The older HS destination does not handle it either.
On rollout: operator#1775 leaves noOfWorkers at the default 64 for HS_AUDIENCE, and lookups are not bounded per token. I asked there whether 64 is intended.
🔒 Scanned for secrets using gitleaks 8.28.0
🔒 Scanned for secrets using gitleaks 8.28.0
am6010
left a comment
There was a problem hiding this comment.
Approving. The empty-2xx fix, hs_additional_emails matching, ConfigurationError for a missing token or list id, and the network.js comment fix all hold.
Not blocking:
- A 408 still aborts as rejected in
delivery.tsandlookup.ts.intercom_v2retries it. network.jsstill hard-codesHS_AUDIENCE. A statTags flag would be cleaner.- The failing "Verify generated secret paths" check should clear once integrations-config#2798 is released and the package is bumped here.
- Before GA, the live run should still cover merged contact ids.
🔒 Scanned for secrets using gitleaks 8.28.0
🔒 Scanned for secrets using gitleaks 8.28.0
ACT2-1230 review (#5681), as in HubSpot #5638. processAxiosResponse maps a Node transport failure without an HTTP status (ENOTFOUND, EPIPE, ...) onto a synthetic 400 with a `[CODE] :: ...` body, which delivery and the email lookup treated as a permanent rejection. - delivery: a 400 whose body is a Node transport message retries every job ('Marketo request failed (network error)'). - lookup: a client response with no HTTP status throws a RetryableError ('Marketo lead lookup failed (network error)') before processAxiosResponse.
…ssion ACT2-1230 review (#5681), as HubSpot #5638 did in c4d8bff. Request and response payload logs are written only at LOG_LEVEL=event, a global setting that already controls them, so a per-destination suppression in commonHandler is not needed. src/adapters/network.js and network.test.js match develop again.
…work default ACT2-1230 review (#5681), as in HubSpot #5638. The framework already retries a 5xx, so the explicit '5xx' status override restated the default. The 2xx handling and the 4xx override through perItem stay; the header comment and the 5xx test now describe and expect the framework's retryable throw.
…sted ACT2-1230 review (#5681), as HubSpot #5638 did in 8f1edcc. A returned lead for an address the chunk did not ask for says nothing about the requested emails, so it is now skipped instead of retrying the whole chunk; the other emails resolve as usual. A lead with no email, or a matched email with an invalid id, still retries the chunk as uncorrelated.
🔒 Scanned for secrets using gitleaks 8.28.0
🔒 Scanned for secrets using gitleaks 8.28.0
🔒 Scanned for secrets using gitleaks 8.28.0
|
…nation (#5681) ## What are the changes introduced in this PR? Adds `MARKETO_AUDIENCE`, a batching-framework destination that adds leads to, and removes them from, an existing Marketo static list. It is used by rETL and by Lookout activations. - **`src/v0/destinations/marketo_audience/`** (`DestinationIntegration`, registered `{ routerTransform: true, batching: true }` in `src/features.ts`): - **`transformEvents` override (pre-stage), run once per batch before `super.transformEvents`:** - fetches the token once per call, using the shared `getAuthToken` and a `MARKETO_AUDIENCE_AUTH` cache. A failed token call gets a fixed reason per class (throttled, retry, or abort with its status), so Marketo's message text never reaches a row; a network failure with no HTTP status retries; - checks each row's own list and identifiers; - looks up emails in batches (up to 300 per `POST /rest/v1/leads.json?_method=GET`, with a `URLSearchParams` form body). A returned lead whose email wasn't requested is ignored, so it can't fail the other emails in the batch; a network failure with no HTTP status retries the rows. A 1003 (more than 1,000 leads match) halves the batch until single emails remain, so only the email that still returns 1003 fails, with "More than 1,000 Marketo leads match this email". A `nextPageToken` is followed even when `moreResult` is absent. - **Rows:** if the router input both adds and removes one lead on one list, every row for that lead fails, including a `dontBatch` row that the framework transforms in a separate call. Each later row naming a lead already seen goes in its own request. Every failure is a typed error on its own row; an unexpected pre-stage error fails the remaining rows with a retryable error and is logged with its error name and stack frames only (no message text, which can contain emails). - **`transformEvent`:** synchronous. Builds one `POST`/`DELETE /rest/v1/lists/{listId}/leads.json` per row with `Authorization: Bearer`. - **Batching:** `ChunkBatchStrategy` of 300 lead IDs, body `{ input }`. - **`delivery.ts`:** overrides 2xx, 4xx and 5xx, and every verdict goes through `perItem`, so the raw body stays out of job errors. 2xx: Marketo's HTTP-200 responses become one verdict per job, matched by lead ID (codes 1004/1015/1008, token 601/602 eviction, throttled 502/606/608/615 and daily quota 607, 1013, 603). 4xx: abort, except the proxy's synthetic 400 for a network failure (EPIPE, ENOTFOUND…), which retries because Marketo never saw the request. 5xx: retry with a fixed reason. No lead ID, email or Marketo message text appears in any reason. - **`secretPaths.json`:** `"MARKETO_AUDIENCE": ["headers.Authorization"]`, so Live Events masks the token. - **`test/integrations/destinations/marketo_audience/`:** router (8 cases), dataDelivery (9 cases), network mocks. ## What is the related Linear task? Resolves ACT2-1230 (parent ACT2-1013) ## Please explain the objectives of your changes below Spec: [rudder-specs#214](rudderlabs/rudder-specs#214), §6.3, decisions D5–D12. Pattern: HubSpot `hs_audience` (#5638). **Dependencies and merge order:** - `check:secret-paths` passes: the `marketo_audience` definition (rudder-integrations-config #2836, ACT2-1228) is merged to config `main`. - Operator values (router batch, proxy, throttle) are in rudderstack-operator ACT2-1233. Delivery needs `transformerProxy: true`. ### Any changes to existing capabilities/behaviour, mention the reason & what are the changes ? N/A. No shared code changes; `network.js` is untouched. Following the review of #5638, there's no per-destination log suppression: request bodies reach network logs only at the global `LOG_LEVEL=event`. ### Any new dependencies introduced with this change? N/A ### Any new generic utility introduced or modified. Please explain the changes. N/A. `getAuthToken` is reused unchanged. This destination strips the shared error when Marketo returns `expires_in: 0`, because that error contains the token. MARKETO and MARKETO_STATIC_LIST still have that leak; it's out of scope here. ### Any technical or performance related pointers to consider with the change? - **Token:** at most one identity call per batch. A failed fetch fails every remaining row once. 601/602 from the lookup or delivery evicts the cached token, per pod; a later `dontBatch` call on the same instance then fetches a new one. - **Daily quota (607):** throttled, as in MARKETO and MARKETO_STATIC_LIST. Rows retry until Marketo resets the quota at 12:00 AM CST, and the rETL sync stays running until then. - **Repeated leads:** if two rows resolve to the same lead with the same operation (the same Lead ID twice, or a Lead ID and an email for one lead), they go in separate requests via `internalGroupKey`. No request holds a lead ID twice, so delivery matches each result to its job by lead ID. - **Accepted for v1:** with `LOG_LEVEL=event`, network logs include the lookup body (up to 300 emails) and the identity response, the same as other destinations today (documented in the spec's observability notes). **Not covered (phase 2, waiting on Marketo credentials):** - `live.ts` is left out until `LIVE_SECRET_MARKETO_AUDIENCE` exists in Vault. The live matrix ignores `enabled: false` and would fail on every push. - Live checks: - POST and DELETE accept the JSON `input` body, and result IDs echo the sent IDs. - The status for re-adding a member and for removing a non-member. - Case-insensitive email lookup through the `_method=GET` form post. - Real 606/607/1008 bodies and paging. - What Marketo echoes for a merged lead. <hr> ### Developer checklist - [x] My code follows the style guidelines of this project - [x] **No breaking changes are being introduced.** - [x] All related docs linked with the PR? - [ ] All changes manually tested? (mocked only; live checks in phase 2) - [ ] Any documentation changes needed with this change? - [ ] Is the PR limited to 10 file changes? (18 files: one new destination plus its tests and fixtures) - [x] Is the PR limited to one linear task? - [x] Are relevant unit and component test-cases added in **new readability format**? **Checks** (Node 22, the repo's pinned major): - The pre-commit hook (`test:ts`, `test:js`, lint-staged, commitlint) passed on every commit; the latest run had `test:ts` 128 suites and `test:js` 101 suites. - Component tests (`--destination=marketo_audience`) pass, and `tsc --noEmit` on src and test is clean. ### Reviewer checklist - [ ] Is the type of change in the PR title appropriate as per the changes? - [ ] Verified that there are no credentials or confidential data exposed with the changes. 🤖 Generated with [Claude Code](https://claude.com/claude-code)



🔒 Scanned for secrets using gitleaks 8.28.0
What are the changes introduced in this PR?
Adds the HubSpot Audience destination so warehouse / audience rows can add and remove contacts on an existing HubSpot list. Membership sync only — not contact create/update like classic HubSpot. Covers transform, batching, delivery response handling, and tests (unit, component, live scaffolding).
What is the related Linear task?
Resolves ACT2-1015
Please explain the objectives of your changes below
Transformer piece of HubSpot Audience v1 (Splashtop first). Customers sync a warehouse table, SQL model, or audience into a MANUAL/SNAPSHOT HubSpot contact list. Lookout is a second way to configure the same destination later — not a separate HubSpot path.
Depends on / ships with:
AMP_enable-hs-audience-destination)Router.HS_AUDIENCEbatch settings (operator/devops — out of this PR)Any changes to existing capabilities/behaviour, mention the reason & what are the changes ?
N/A for product behavior. Small network-adapter tweak so proxy delivery can attach the bearer token without putting it on persisted router output (live events stay token-free).
Any new dependencies introduced with this change?
N/A
Any new generic utility introduced or modified. Please explain the changes.
N/A — destination-local helpers only. Built on the existing DestinationIntegration batching / delivery framework.
Any technical or performance related pointers to consider with the change?
Developer checklist
Reviewer checklist