Repository navigation
fix: group router transform events by source job so concurrent syncs reach their own list - #5705
Conversation
…reach their own list
groupRouterTransformEvents read `ev.context?.sources?.job_id`, but router
inputs are `{ message, metadata, destination, connection }`, so the key was
always 'default'. Every rETL sync on one destination fell into one group, and
the batching framework built the integration from that group's first
connection: rows from a second concurrent sync went to the first sync's
list or audience while both runs reported success (ACT2-1257).
Key on `metadata.sourceJobId`, falling back to
`message.context.sources.job_id`. Event-stream jobs carry neither, so their
grouping is unchanged.
- rewrite the grouping unit tests with the real router input shape
- add a two-connection router case for custom_audience, reddit_audience,
iterable_audience, hs_audience and braze_audience
- update marketo_static_list, mailchimp, google_adwords_offline_conversions
and customerio_audience fixtures: rows with and without a source job id
now batch separately (same per-row output, regrouped or reordered)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
rudder-server's router request metadata has no source job field, so the `metadata.sourceJobId` branch never matched in production; the source job id reaches the transformer only as `message.context.sources.job_id`. Key on that alone, and make the tests use the shape the router actually sends: - grouping unit tests build the job id on the message only - the five two-connection router cases give each row its own `message.context.sources.job_id` and a `metadata.sourceId` matching its connection, instead of `metadata.sourceJobId` Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
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 #5705 +/- ##
========================================
Coverage 92.28% 92.29%
========================================
Files 731 731
Lines 40616 40633 +17
Branches 9513 9441 -72
========================================
+ Hits 37484 37502 +18
- Misses 2868 2947 +79
+ Partials 264 184 -80 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
… read one connection per group linkedin_audience, fb_custom_audience (VDM v2), google_adwords_remarketing_lists (VDM v2 legacy and Data Manager), customerio_audience and zoho (VDM v2) take the list, audience or module from one connection for the whole router group, so they had the same wrong-list bug as the five audience destinations covered earlier (ACT2-1257). Each new case sends two rows from two syncs (own connection, own message.context.sources.job_id) and expects one request per target; each fails on the old grouping key. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review panel: Approve with follow-upsReviewed at Live check (rudder-mini, Custom Activation, two mirror syncs started in the same second)
Findings
Held up
Limits
|
am6010
left a comment
There was a problem hiding this comment.
Approving: the key fix is right, and the new cases prove it. Before merge, ideally (not blocking): add two-sync tests for CUSTOMERIO and hs rETL, and fix two lines in the description. Also one FYI on Braze.
I checked the router input shape against rudder-server master:
- Inputs arrive as
{message, metadata, destination, connection}. - The compacted payload is expanded before grouping (
routes/destination.ts:21-28→routerTransformCompactedPayloadV1.ts:31). JobMetadataTsends no source job id:Parametersisjson:"-", andDehydrate()clearsJobT.- The server only splits router calls by OAuth destination (
worker.go:236-260).
So message.context.sources.job_id is the right key, and the fix is not redundant with anything on the server side. With the key reverted, the router suite fails only the 11 new cases and the 4 updated fixtures, and every new case fails because the second sync lands on the first sync's target.
1. FYI, not blocking: Braze supportDedup can keep an older value. Each group builds its own dedup lookup (braze/transform.ts:618-630), and groups run concurrently. When one user's rETL row and SDK row land in the same router call, the SDK group dedups against Braze's old state and can drop the newer update as "Duplicate user detected". We reproduced it through doRouterTransformation. It's a rare case, so I'm fine shipping as is. One line in the description is enough.
2. CUSTOMERIO and hs rETL have the same bug and this PR fixes both, but neither has a test or a row in the table.
- CUSTOMERIO is GA on the batching framework (
features.ts:81).vdmV2ObjectDestination.ts:139-145readsobjectfromthis.connection, which is the group's first connection (processDestinationIntegration.ts:219). On the old key, an event-object sync's row goes out as a person identify, withattributes.name: 'Order Completed'overwriting the person's name. hsrETL picks the path frominputs[0](hs/transform.ts:56-60; the comment "a router call is homogeneous per source" is not true ondevelop). It takesobjectTypeandidentifierTypefrom the first row (retl-transform.ts:66-70,util.ts:739-745).- A contacts sync and a companies sync in one call: on the old key, the companies row goes to
/crm/v3/objects/contacts/batch/upsert. - An rETL row and an SDK row in one call: on the old key, whichever kind isn't first fails with 400.
- A contacts sync and a companies sync in one call: on the old key, the companies row goes to
Could you add one two-sync router case for each (customerio: person + event; hs: contacts + companies) and add both to the table? I'll ask for them to be added to the ACT2-1257 exposure count on our side.
3. Two claims in the description don't hold.
- "Per-row output is unchanged" is refuted by point 1.
- "Delivery order for one user can now differ when … the second group's request fails" is also incomplete: order changes on the success path too. rudder-server sends destination jobs sorted by
MinJobID(router/worker.go:442-444). One user's SDK rows j1 and j3 become one batch (min 1) and the rETL row j2 another (min 2). So[j1, j3]is delivered before[j2], and j2's older value is the one that sticks, with every request succeeding.
Dynamic-config groups already behave this way, so I don't think it blocks, but the description should say it.
Nits:
src/v0/util/index.js:2465-2466: the JSDoc still says "groups the events by destination ID, source ID … sourceID is only used for rETL events". It is the source job id now, and it applies to every row.src/v0/util/index.test.js(thegroupRouterTransformEventsblock, ~791-890): the rewritten tests only check group counts and sizes. The old ones checked which rows landed in each group. Two edge cases are also gone:sources: {}without ajob_id, and a missing destination ID with ajob_id. One assertion on group membership would bring that back.customerio_audience/router/data.ts:282-312: the "Error Case" comments are now out of order (3, 4, 2).- The description says each new case "is the only case in its suite" that fails on the old key. That isn't true for
customerio_audience: the existing "Comprehensive router test" fails there too, which is expected after its reorder. - Optional: no case covers the
isHashRequiredmismatch the description mentions (Custom Activation / Reddit).
Possible follow-up, not for this PR: the user-transformation gap (a UT that rebuilds the message without context.sources merges syncs again) could be closed by adding metadata.sourceId to the key for rETL rows only, e.g. metadata.sourceCategory === 'warehouse' ? metadata.sourceId : 'default'.
- That element can only split groups further.
- It survives a UT, because the server stamps
sourceIdandsourceCategoryin router metadata (worker.go:169). - It changes none of the existing fixtures.
- Keying every row on
sourceIdis not a good idea: it would split event-stream batches per source for every router destination.
… tests Review on #5705 found two more destinations that take their target from one row for the whole group: customerio (VDM v2 objects read `object` from the group's connection) and hs rETL (path, objectType and identifierType from inputs[0]). Add a two-sync router case for each; both fail on the old grouping key (event rows sent as person identifies; company rows sent to the contacts upsert endpoint). Also from review: - grouping unit tests assert which rows land in each group, and cover sources without job_id and a missing destination id again - JSDoc describes the source job id key - customerio_audience error-case comments follow output order Co-Authored-By: Claude Opus 5.5 <[email protected]>
…r payloads Give the customerio rows a destination ID and the hs rows the job_run_id / task_run_id fields rudder-sources sends. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks @am6010, all of it taken. Fixed in cbc40b9 and 46940a7; the push dismissed your approval, so it needs a re-approve. 1. Braze 2. CUSTOMERIO and
Each fails only that case in its suite when the key is reverted. 3. Description. "Per-row output is unchanged" is gone. The ordering line now describes the success path: requests are sent sorted by lowest job id ( Nits:
Not added: an Follow-up: your Full router suite: 593 passed, 1 skipped. Unit: 223/223. Secret-paths check: no drift. |
|
am6010
left a comment
There was a problem hiding this comment.
Re-approving at 46940a7. Checked locally: router suite 593 passed / 1 skipped, unit 223/223. With the key reverted, 18 router cases fail (the 13 two-sync cases, including the new customerio and hs ones, plus the 5 regrouped fixture cases) and 4 grouping unit tests fail. The description now covers Braze, ordering, CUSTOMERIO and hs. Agree on skipping the isHashRequired case, and on a separate ticket for the user-transformation gap.



What are the changes introduced in this PR?
When two rETL syncs feed the same audience destination and their runs overlap, rows from one sync are sent to the other sync's list, and both runs report success.
Cause: rudder-server sends every job of a destination in one
/routerTransformcall.groupRouterTransformEventsis meant to split those rows per source job (that was #3496), but it readev.context?.sources?.job_id. Router inputs are{ message, metadata, destination, connection }, socontextis undermessage, and the key was always'default'. Every sync on a destination landed in one group, and the batching framework builds the integration from the group's first connection (processDestinationIntegration.ts), so every request went to that connection's list.Fix: key on
ev.message?.context?.sources?.job_id. That is the only place the source job id reaches the router transform: rudder-server's router metadata (router/types/types.goJobMetadataT) has no source job field.Exposed on
develop(each takes the list / audience / module from one connection for the whole group):custom_audience)this.connectionConfig(endpointaudienceId,isHashRequired)audienceIdfromthis.connectionConfigthis.connectionaudienceIdfromthis.connectioncustomAttributeNamefromthis.connectionConfigaudienceIdfrom the first row of each action group (transform.ts)groupedRecordInputs[0].connection(recordTransform.ts)[0].connection(recordTransform.ts,dataManager/recordTransform.ts)inputs[0].connection(segment,id_type)inputs[0].connection(objectmodule,identifierMappings)objectfromthis.connection(vdmV2ObjectDestination.ts): an event sync's rows went out as person identifiesobjectType/identifierTypefrominputs[0](hs/transform.ts,retl-transform.ts): a companies sync's rows went to the contacts upsert endpointGainsight PX, Marketo and Pinterest Audience read each row's own connection and put the target in that row's request, so they were already safe (unchanged here).
When the two connections have different
isHashRequired(Custom Activation, Reddit), the second sync's rows were checked against the first sync's flag and rejected as instrumentation errors ("Hashing is disabled but the value … appears to be unhashed"); nothing was sent unhashed.Explainer: https://rudder-office.fly.dev/docs/audience-wrong-list-concurrent-syncs.html
What is the related Linear task?
Resolves ACT2-1257
Please explain the objectives of your changes below
src/v0/util/index.js: grouping key fix (one line) and comment.src/v0/util/index.test.js: grouping tests rewritten with the real router input shape. The old tests putcontextat the top level, a shape production never sends, so they passed on the broken key.custom_audience,reddit_audience,iterable_audience,hs_audience,braze_audience,linkedin_audience,fb_custom_audience,google_adwords_remarketing_lists(legacy and Data Manager),customerio_audience,zoho,customerio(person + event objects),hs(rETL contacts + companies). Two rows on one destination, each with its ownmessage.context.sources.job_id, connection and matchingmetadata.sourceId(the shape rudder-server sends), asserting each request goes to its own list / module. Each case fails on the old key; the only other cases that fail there are the four regrouped fixtures below, which return to their old grouping.Any changes to existing capabilities/behaviour, mention the reason & what are the changes ?
Rows that carry different source job ids, or a job id vs none, are now transformed in separate groups for every router destination. That is what #3496 intended. Effects:
context.sources.job_id, so its batching is unchanged. Events that do carry one (cloud/ETL extract sources run by rudder-sources, or a client that setscontext.sources.job_iditself) now batch per job, in smaller batches.router/worker.go:442-444), so with SDK rows j1, j3 in one group and an rETL row j2 in another,[j1, j3]is delivered before[j2]and j2's older value lands last, even when every request succeeds. If the second request fails, j3 is already delivered while j2 retries. Before, all three shared one request. Groups of an audience destination write different lists, so this matters only for destinations that mix one user's rETL and event-stream rows; dynamic-config grouping already behaves this way.supportDedup: each group builds its own dedup lookup against Braze's current state (braze/transform.ts:618-630) and groups run concurrently, so when one user's rETL row and SDK row land in the same router call, the SDK group can drop the newer update as "Duplicate user detected". Rare; noted rather than handled here. Four existing fixtures had such mixes and were updated:marketo_static_listandcustomerio_audience(reorder only),mailchimpandgoogle_adwords_offline_conversions(one batch becomes two, same rows and payloads).Any new dependencies introduced with this change?
N/A
Any new generic utility introduced or modified. Please explain the changes.
groupRouterTransformEvents(shared bynativeIntegration.tsandcdkV2Integration.ts): grouping key reads the job id frommessage.context.sources.job_idinstead of the non-existent top-levelcontext.Any technical or performance related pointers to consider with the change?
context.sources.job_idsharing a destination with other traffic). At most one extra partial batch per extra group.google_adwords_offline_conversionsstore sales: a mixed call now creates one offline user data job per group instead of one shared job.context.sourcesputs that sync's rows back in the default group.Verification
src/v0/util/index.test.js223/223.npm run test:ts -- component --feature=router593 passed, 1 skipped.npm test -- src/v0 src/services src/cdk src/v1: 3293 passed.check:secret-pathsagainst integrations-configmain: no drift.LIST_A/LIST_Bfrom two 500-row tables, both full syncs started in the same second:/LIST_A/LIST_Bdevelopimage (old key)Pre-ready review
Independent review before opening, then a five-lens review panel (security, correctness, product, ops, coherence) with blinded adversarial checks on each finding and load-bearing claim. Findings and rulings:
metadata.sourceJobIdfirst, and the new component cases only set that field. rudder-server never sends it on router requests, so the tests covered a path production doesn't take. Fixed in 98cf63f: key only on the message job id; cases now use the shape the router sends.metadata.sourceIdnow matches each row's connection.context.sources. A possible follow-up is to also key rETL rows onmetadata.sourceId(which the router does send) so a transformation cannot merge two syncs.job_id(config-backend starts each rETL sync with its connection id;unique_source_destinationon connections), and one connection keeps onejob_idacross runs and retries (checked in livert_jobs).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?
Any documentation changes needed with this change?
Is the PR limited to 10 file changes? (32: 2 source/unit files, 30 component fixtures)
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.
🤖 Generated with Claude Code