Repository navigation
feat(marketo_audience): marketo audience static list membership destination - #5681
Conversation
Router-only batching-framework destination for MARKETO_AUDIENCE (ACT2-1230).
- transformEvents pre-stage: per-row list ID and identifier checks, one
access token per call through the shared marketo getAuthToken and a
module-level MARKETO_AUDIENCE_AUTH cache, one email lookup per batch
(POST /rest/v1/leads.json?_method=GET, 300 emails per call, paged), and
add/remove conflict detection per lead and list.
- transformEvent: one {id} item per row, POST or DELETE to the row's own
list, Authorization set at transform time; token errors are re-raised
without the identity response body, which can carry the token.
- ChunkBatchStrategy with 300 lead IDs per request, body {input: [...]}.
- Delivery spec: positional per-lead verdicts on 2xx, success:false code
classification, token eviction on 601/602, all verdicts via perItem.
- features.ts: MARKETO_AUDIENCE { routerTransform: true, batching: true }.
…k logs ACT2-1230. The email lookup body carries up to 300 customer emails and the membership request and responses carry Marketo lead IDs, so commonHandler skips request/response event logs for destination types listed in PAYLOAD_LOG_SUPPRESSED_DEST_TYPES (MARKETO_AUDIENCE). Latency, count and payload-size metrics are still recorded. The set lets HS_AUDIENCE (#5638) join without a second branch.
ACT2-1230. - router/data.ts: lead-ID add/remove, email lookup (found, missing on add and remove, duplicate leads), per-row lists, row errors, conflict, throttled lookup, rejected client credentials, non-Munchkin accountId. - dataDelivery/data.ts: added, 1004 on add, 1004/1015 on remove, 1008, result-length mismatch, 601, 606, 607, 1013. - network.ts: documented Marketo envelopes and the shapes already captured for MARKETO_STATIC_LIST; no live instance was available. - live.ts: enabled: false until a Marketo sandbox exists. Its scenarios cover the spec's live checks (JSON input body on POST/DELETE, re-add and non-member remove results, case-insensitive email lookup).
ACT2-1230. Derived with the secret-path generator (SECRET_PATHS_DESTINATION=marketo_audience) against the ACT2-1228 integrations-config definition (secretKeys clientId, clientSecret): the token fetched with them lands in headers.Authorization. Merged into the full artifact; no other entry changes. CI's check:secret-paths reads integrations-config main and passes once ACT2-1228 is merged there.
…equest ACT2-1230 review. Two rows of one call can name the same lead on the same list and operation: the same lead ID twice, a lead ID and an email that resolves to it, or the same email twice. Delivery verdicts are positional, so one request must carry each lead ID at most once, and Marketo's answer to a repeated ID is unverified. The pre-stage now numbers each copy of a (list, lead, operation) and transformEvent sets internalGroupKey to that number, so the n-th copy goes to the n-th request. No fan-out, no dedupe.
…-stage error
ACT2-1230 review. Expected failures (token, lookup, row checks) are already
typed on their own rows. Anything else that escaped the transformEvents
override would fail every job of the destination group with an untyped
error. The pre-stage now runs inside a try/catch that gives each row not
already failed a RetryableError ('Marketo Audience could not prepare the
row'); rows with their own error keep it.
ACT2-1230 review. .github/scripts/live-test-matrix.js enrolls every destinations/*/live.ts and ignores `enabled: false`, so the live job would fail at the Vault import of LIVE_SECRET_MARKETO_AUDIENCE on every push to develop. The spec returns in phase 2, once that secret exists.
|
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 #5681 +/- ##
===========================================
+ Coverage 92.16% 92.28% +0.11%
===========================================
Files 719 731 +12
Lines 40017 40616 +599
Branches 9367 9512 +145
===========================================
+ Hits 36883 37483 +600
Misses 2869 2869
+ Partials 265 264 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…message ACT2-1230 review (#5681). Since the pre-stage catch types an unexpected error onto each row, a programming bug no longer reaches error reporting. The catch now logs it at error level with destType, destinationId, workspaceId, the error name and its stack frames only. The message line(s) are dropped, because V8 repeats the message at the top of the stack and it can carry emails or Marketo text. No new metric.
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.
…arketo-audience-bf3766 # Conflicts: # src/features.test.ts # src/features.ts
lvrach
left a comment
There was a problem hiding this comment.
Approving. Nothing here blocks the merge. Three [minor] comments ask for retry and error-text fixes; the rest are optional.
- The tests are strong: 10 of 10 executed mutants failed the unit tests (email lower-casing, POST/DELETE swap, 300 split, token eviction, 1004 handling, the add+remove conflict check and more).
- [fyi] The operator limit (rudderstack-operator#1819) counts only membership calls. Each batch also makes lookup and token calls, so Marketo sees more calls than the limit shows.
Not covered: no live Marketo run. The body-only DELETE is not in Adobe's list-membership page (it shows id query parameters), so keep it on the phase 2 live checklist.
Reviewed by an agent fleet for @lvrach (Claude Opus + OpenAI astra/sol lanes, validators re-ran each claim that could block). LLM findings, needs human review.
lvrach
left a comment
There was a problem hiding this comment.
Second pass after a Marketo docs check (Adobe Experience League, the Marketo Swagger, marketorestpython, Segment's static-list source). Still approving. Nothing here blocks the merge.
Confirmed: the JSON body on DELETE reaches the wire (a test sent it through proxyRequest to a local server), and Adobe's Swagger requires it for removals. Every data call uses the Bearer header. Lookup paging follows the documented moreResult contract.
- [suggestion] Token cache:
getAuthTokencaches for exactlyexpires_in. A token with a few seconds left can go out after it expires and costs one retry with 602. Treat a shortexpires_inlike 0. - [nit] The 603 reasons (
delivery.ts:120,lookup.ts:137) name a missing lead permission. Adobe's 603 also covers the IP allowlist and a missing Bearer token, so "Marketo denied access" is safer.
Agent fleet for @lvrach, Claude Opus and OpenAI astra lanes. LLM findings, needs human review.
…ting ACT2-1230, review on #5681. Marketo resets the daily quota at 12:00 AM CST, so a later retry succeeds. A 607 on a membership call or an email lookup is now throttled with the reason "Marketo daily API quota reached", as MARKETO, MARKETO_STATIC_LIST and integrations-info do. rudder-server retries throttled jobs without counting them against the retry limit, and Marketo does not charge calls that return a limit code.
…ry transport errors ACT2-1230, review on #5681. The token step kept the shared getAuthToken error as-is, so a Node transport failure (ENOTFOUND, EPIPE), which nodeSysErrorToStatus maps to 400, aborted every row, and Marketo's own message text reached the row reason. Token failures now map to a fixed reason per class: 429 throttles ("Marketo rate limit reached on the access token request"), 5xx, an expired token and a transport failure retry ("Marketo access token could not be fetched"), and any other status aborts with that status ("Marketo rejected the access token request"). The transport check is shared with delivery.
… job errors ACT2-1230, review on #5681. Without a 5xx override the framework retried the batch through TransformerProxyError, whose destinationResponse put Marketo's raw body, which can contain an email, into every job's error. A '5xx' override now returns a per-job retry with the fixed reason "Marketo request failed (HTTP <status>)", like the 4xx branch.
ACT2-1230, review on #5681. Marketo's list-membership answer has one result per sent lead but does not promise input order, so a reordered answer retried every job although the writes succeeded. Results are now looked up by lead ID; internalGroupKey already keeps each ID once per request. The count check stays, and a result for an unsent lead or a lead listed twice still retries the batch as unmatched.
…the same instance ACT2-1230, review on #5681. The framework calls transformEvents again on the same instance for each dontBatch row, and `tokenRequest ??=` kept the first token for the instance's life, even after a lookup 601/602 evicted it from the cache, so the dontBatch membership request failed with 602. The memoised request is now dropped when the cache no longer holds the token this instance fetched; without an eviction the token is still reused.
ACT2-1230, review on #5681. Code 603 covers a missing Read-Only or Read-Write Lead permission and other access refusals, so naming one permission could mislead. Membership and lookup responses now share the reason "Marketo denied access"; the verdict (abort) is unchanged.
… stack frames ACT2-1230, review on #5681. A message line that starts with " at " passed the frame filter, so `new Error('lookup bug for\n at [email protected]')` logged the address. The pre-stage log now drops as many stack lines as the message has before keeping frames.
…Result ACT2-1230, review on #5681. Adobe documents moreResult: true with the token for filter-type reads, but some Marketo endpoints send only the token. The lookup stopped after page 1 in that case, so an email whose lead was on page 2 failed as not found. A non-empty nextPageToken is now followed when moreResult is absent; moreResult: false still ends paging, and moreResult: true without a token still retries the chunk.
…ansform calls ACT2-1230, review on #5681. The framework transforms the batchable rows in one transformEvents call and each dontBatch row in a call of its own, and the conflict check only saw one call, so a batched insert and a dontBatch delete of the same lead on the same list both went out. The destination cannot see the router input before the framework splits it, so the check now carries each lead's operations and deliverable jobs across the calls on the instance. A later conflicting row fails, and the earlier jobs get a CONFLICTING_MEMBERSHIP error in the same result; the framework drops a failed job from every success payload before it builds requests, so the earlier request never carries it.
…ng all its rows ACT2-1230, review on #5681. Marketo answers 1003 with no partial pages when more than 1,000 leads match the filter, so one email with many duplicate leads aborted every email in its 300-email chunk. A 1003 now halves the chunk and retries each half until single emails remain; only an email that still returns 1003 alone fails, with "More than 1,000 Marketo leads match this email". Throttle and retry handling for the other codes is unchanged.
|
lvrach
left a comment
There was a problem hiding this comment.
Approving again at c543f42. All 10 fixes do what their commits say. The 154 unit tests and 17 component tests pass. 6 of 7 mutants on the new code fail a test. The three items below do not block the merge.
Agent fleet for @lvrach: Claude Opus and OpenAI astra lanes on the 10 new commits. LLM findings, needs human review.
[minor, test gap] routerTransform.test.ts: Without the line this.earlierConflicts = [], all 36 router tests still pass. Please add one test with 4 rows: a batched add, then a dontBatch add, a dontBatch remove and a dontBatch add. Each job must receive exactly one error.
…ique lead IDs (#5704) ## What are the changes introduced in this PR? Follow-up to #5681 for MARKETO_AUDIENCE. It fixes the 3 items @lvrach left at c543f42, one commit each. Only `src/v0/destinations/marketo_audience` and its unit tests change. 1. **Cap on 1003 splits** (review comment 4323376958, then 4327977981, `lookup.ts`). A 1003 split sent its lookups one after another with no limit: if every 20th email matches more than 1,000 leads, one 300-email chunk made 163 calls. One `lookupLeadsByEmail` call (one per `transformEvents` call) now makes at most 19 lookup calls. Every page counts, and all chunks of the batch share the budget. 19 calls is what splitting one email out of a 300-email chunk takes when each lookup fits in one page (one lookup, then nine halvings of two), and it is under a fifth of Marketo's 100 calls per 20 s per instance. Without a 1003, a chunk reads at most 4 pages, so for up to 1,200 emails only a split reaches the cap. Emails still unresolved when the budget runs out retry with the fixed reason `Marketo lead lookup split limit reached (code 1003)`, and every email still gets exactly one outcome. A lookup cut short mid-pages drops its partial matches, so all of its emails retry. The retry carries fewer rows, because the rows split out or resolved in this pass are gone. 2. **Token memo** (review comment 4323376968, `routerTransform.ts`). A dontBatch row's call now uses the memoised token only while it equals the cached one. Otherwise it clears the memoised token and the pending request together. This fixes both reported cases: - After a refetch fails, the later dontBatch rows fail with that error without calling identity again. Before, 200 rows with a 401 identity made 201 calls. - When another request has cached a newer token B, the row takes B instead of sending its own older token A. 3. **Unique sent lead IDs** (review comment 4323376974, `delivery.ts`). A lead ID sent twice would let one result answer two jobs. That now retries the batch like any other unmatched response. The router can't send a duplicate today (`internalGroupKey` keeps IDs unique per request), so this is only a second defence. ## What is the related Linear task? Part of ACT2-1230 (parent ACT2-1013): review follow-ups from #5681 ## Please explain the objectives of your changes below #5681 was merged without these 3 non-blocking items so it would keep its approval; this PR fixes them. Both Marketo Flagsmith flags (`enable-marketo-audience-destination`, `enable-lookout-marketo-audience-activation`) are off in every environment, so no traffic reaches this code until the flags are turned on. Each item started as a failing test (known-bad run before each fix): | Item | Test | Before the fix | |---|---|---| | 1 | `stops after 19 lookup calls and retries the emails left` | 163 calls instead of 19 | | 1 | `counts each page call against the limit` (first email 1,001 leads, others 3) | 20 calls instead of 19 | | 1 | `shares one call limit across the chunks of one lookup` (1,200 emails, one 1003 per chunk) | 76 calls instead of 19 | | 2 | `fails later dontBatch rows without another identity call after a refetch fails` | 4 identity calls instead of 2 | | 2 | `sends the token another request cached, not its own older one` | `Bearer token-a` instead of `Bearer token-b` | | 3 | `retries every job: the same lead sent twice` | both jobs `success` instead of retry | ### Any changes to existing capabilities/behaviour, mention the reason & what are the changes ? Only MARKETO_AUDIENCE, which is behind flags that are off. A chunk with many 1003 emails now retries the rows it could not resolve instead of making unlimited calls. ### Any new dependencies introduced with this change? N/A ### Any new generic utility introduced or modified. Please explain the changes. N/A. The shared `marketo/util.js` is unchanged. ### Any technical or performance related pointers to consider with the change? The cap covers one `transformEvents` call: every chunk of the batch and every page count against it. The router transforms each dontBatch row in a call of its own, so each of those calls gets its own budget. Not covered: Marketo calls from other `transformEvents` calls, requests or pods against the same instance. The cap limits one call; it doesn't pace the instance as a whole. <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: unit and component tests) - [ ] Any documentation changes needed with this change? - [x] Is the PR limited to 10 file changes? (7 files) - [x] Is the PR limited to one linear task? - [x] Are relevant unit and component test-cases added in **new readability format**? ### 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. ### Checks run locally - marketo_audience unit tests: 160 passed (154 before, plus 6 new) - marketo_audience component tests (router + proxy v1): 17 passed - Pre-commit hook on each commit (latest e8ff489): ts 6527 passed / 2 skipped, js 2021 passed, lint-staged clean - `tsc --noEmit`, eslint and prettier clean; `generate:secret-paths` for marketo_audience gives the same `["headers.Authorization"]` 🤖 Generated with [Claude Code](https://claude.com/claude-code)



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 }insrc/features.ts):transformEventsoverride (pre-stage), run once per batch beforesuper.transformEvents:getAuthTokenand aMARKETO_AUDIENCE_AUTHcache. 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;POST /rest/v1/leads.json?_method=GET, with aURLSearchParamsform 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". AnextPageTokenis followed even whenmoreResultis absent.dontBatchrow 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 onePOST/DELETE /rest/v1/lists/{listId}/leads.jsonper row withAuthorization: Bearer.ChunkBatchStrategyof 300 lead IDs, body{ input }.delivery.ts: overrides 2xx, 4xx and 5xx, and every verdict goes throughperItem, 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, §6.3, decisions D5–D12. Pattern: HubSpot
hs_audience(#5638).Dependencies and merge order:
check:secret-pathspasses: themarketo_audiencedefinition (rudder-integrations-config feat: cm360 router batching #2836, ACT2-1228) is merged to configmain.transformerProxy: true.Any changes to existing capabilities/behaviour, mention the reason & what are the changes ?
N/A. No shared code changes;
network.jsis untouched. Following the review of #5638, there's no per-destination log suppression: request bodies reach network logs only at the globalLOG_LEVEL=event.Any new dependencies introduced with this change?
N/A
Any new generic utility introduced or modified. Please explain the changes.
N/A.
getAuthTokenis reused unchanged. This destination strips the shared error when Marketo returnsexpires_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?
dontBatchcall on the same instance then fetches a new one.internalGroupKey. No request holds a lead ID twice, so delivery matches each result to its job by lead ID.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.tsis left out untilLIVE_SECRET_MARKETO_AUDIENCEexists in Vault. The live matrix ignoresenabled: falseand would fail on every push.inputbody, and result IDs echo the sent IDs._method=GETform post.Developer checklist
Checks (Node 22, the repo's pinned major):
test:ts,test:js, lint-staged, commitlint) passed on every commit; the latest run hadtest:ts128 suites andtest:js101 suites.--destination=marketo_audience) pass, andtsc --noEmiton src and test is clean.Reviewer checklist
🤖 Generated with Claude Code