Repository navigation
fix(marketo_audience): cap 1003 splits, clear failed tokens, check unique lead IDs - #5704
Conversation
A 1003 split sent its lookups one after another with no limit: every 20th email matching more than 1,000 leads made 163 calls for one chunk, against Marketo's 100 calls per 20 s per instance. Each 300-email chunk now makes at most 19 lookups, enough to split out one such email; emails still unresolved then retry with a fixed reason. Addresses review comment 4323376958 on #5681.
…ng after a failure After a token fetch failed, the cache stayed empty while the old token stayed memoised, so every later dontBatch row called the identity endpoint again (200 rows with a 401 made 201 calls). And when another request cached a newer token, this instance kept sending its own older one. The memoised token is now compared with the cached one, and both it and the pending request are cleared when they differ; a failed fetch then fails the remaining rows on this instance without another call. Addresses review comment 4323376968 on #5681.
Results are matched to jobs by lead ID, so a lead ID sent twice would let one result answer two jobs. The router cannot send one today (internalGroupKey keeps IDs unique per request); as a second defence, a repeated sent ID now retries the batch like any other unmatched response. Addresses review comment 4323376974 on #5681.
|
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✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #5704 +/- ##
========================================
Coverage 92.28% 92.29%
========================================
Files 731 731
Lines 40616 40633 +17
Branches 9513 9518 +5
========================================
+ Hits 37484 37501 +17
Misses 2868 2868
Partials 264 264 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
lvrach
left a comment
There was a problem hiding this comment.
Approving. All three fixes do what their commits say. The 158 unit tests pass. Each fix has a mutant that fails a test. When a chunk reaches the cap, every email still gets exactly one outcome. One small follow-up, not blocking.
Agent fleet for @lvrach: Claude Opus and OpenAI astra lanes. LLM findings, needs human review.
The 1003 cap counted lookups per 300-email chunk, but each lookup can read up to 4 pages and the cap restarted for every chunk: 300 emails where the first matches 1,001 leads and the others 3 made 20 calls, and 1,200 emails with one such email per chunk made 76. The cap now counts every page call, 19 per lookupLeadsByEmail call (one per transformEvents call), shared by all chunks. Emails still open at the cap keep the fixed retry reason. Addresses review comment 4327977981 on #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_audienceand its unit tests change.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. OnelookupLeadsByEmailcall (one pertransformEventscall) 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 reasonMarketo 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.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: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 (internalGroupKeykeeps 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):
stops after 19 lookup calls and retries the emails leftcounts each page call against the limit(first email 1,001 leads, others 3)shares one call limit across the chunks of one lookup(1,200 emails, one 1003 per chunk)fails later dontBatch rows without another identity call after a refetch failssends the token another request cached, not its own older oneBearer token-ainstead ofBearer token-bretries every job: the same lead sent twicesuccessinstead of retryAny 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.jsis unchanged.Any technical or performance related pointers to consider with the change?
The cap covers one
transformEventscall: 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
transformEventscalls, requests or pods against the same instance. The cap limits one call; it doesn't pace the instance as a whole.Developer checklist
My code follows the style guidelines of this project
No breaking changes are being introduced.
All related docs linked with the PR?
All changes manually tested? (mocked only: unit and component tests)
Any documentation changes needed with this change?
Is the PR limited to 10 file changes? (7 files)
Is the PR limited to one linear task?
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
tsc --noEmit, eslint and prettier clean;generate:secret-pathsfor marketo_audience gives the same["headers.Authorization"]🤖 Generated with Claude Code