Repository navigation
refactor(batch): add record event dispatch to BatchDestination framework - #5324
Conversation
|
Warning Review limit reached
Next review available in: 42 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
Note
|
| Layer / File(s) | Summary |
|---|---|
Single-variant router input schema src/services/destination/nativeBatching/inputSchema.ts, src/services/destination/nativeBatching/__tests__/inputSchema.test.ts |
InputVariant/RouterInput union types removed; SingleRouterInput and a rewritten makeRouterInputSchema build one combined schema from {message, destinationConfig?, connectionConfig?}; tests updated to the single-variant API. |
Union validation error classification src/services/destination/nativeBatching/processBatchedDestination.ts, src/services/destination/nativeBatching/__tests__/processBatchedDestination.test.ts |
validateInputs now resolves invalid_union Zod errors, preferring configuration-only branches, and derives errorType/errorMessage from resolved issues; new tests cover union schema classification. |
VDMV2ObjectDestination base class src/services/destination/nativeBatching/vdmV2ObjectDestination.ts, .../__tests__/vdmV2ObjectDestination.test.ts, .../__tests__/batchDestination.test.ts |
New abstract class exposes getInputSchema (union of record/event-stream schemas), transformObjectRecord contract, transformEventStream default, and transformEvent dispatch with ConfigurationError for unsupported types/actions; new and extended tests validate dispatch behavior. |
Customer.io migration
| Layer / File(s) | Summary |
|---|---|
Schema split and builder cleanup src/v0/destinations/customerio/v2/types.ts, .../v2/recordTransform.ts, .../v2/recordTransform.test.ts, .../v2/util.ts |
customerIOInputSchema split into recordInputSchema/eventStreamInputSchema; validateAction hook removed from RecordPayloadBuilder and buildRecordEvent; deviceActionFor exported; buildEnvelope removed. |
Router transform migration to V2 dispatch src/v0/destinations/customerio/routerTransform.ts, routerTransform.test.ts |
CustomerIO integration switches from BatchDestination to VDMV2ObjectDestination, replacing buildBody/transformEvent with buildRecord, transformObjectRecord, wrapEventStreamBody, transformEventStream; tests updated to async transformEvents with success/error payload assertions. |
Downstream schema call updates
| Layer / File(s) | Summary |
|---|---|
Flattened makeRouterInputSchema calls src/v0/destinations/custom_audience/routerTransform.ts, .../google_adwords_enhanced_conversions/routerTransform.ts, .../iterable_audience/types.ts, .../posthog/routerTransform.ts |
Each destination's schema call changes from a variants: [...] wrapper to passing message/connectionConfig directly, matching the new single-variant contract. |
Estimated code review effort: 4 (Complex) | ~60 minutes
Sequence Diagram(s)
sequenceDiagram
participant Router as RouterTransform
participant VDM as VDMV2ObjectDestination
participant Conn as ConnectionConfig
participant Handler as ObjectActionHandler
Router->>VDM: transformEvent(input, metadata)
alt record input
VDM->>Conn: resolve objectType
Conn-->>VDM: objectType
VDM->>VDM: transformObjectRecord(objectType)
VDM->>Handler: handler(action, identifiers)
Handler-->>VDM: TransformedEvent
else event-stream input
VDM->>VDM: derive messageType
VDM->>VDM: transformEventStream()
VDM->>Handler: handler(message)
Handler-->>VDM: TransformedEvent
end
VDM-->>Router: TransformedEvent or ConfigurationError
Possibly related PRs
- rudderlabs/rudder-transformer#5187: Both modify
validateInputsbehavior in the same native batching pipeline file. - rudderlabs/rudder-transformer#5315: Both modify
validateInputs's Zod error classification/aggregation logic inprocessBatchedDestination.ts. - rudderlabs/rudder-transformer#5311: Both touch Customer.io record-event transformation in
routerTransform.tsandv2/recordTransform.ts.
Suggested reviewers: achettyiitr, krishna2020, ItsSudip
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Description check | The description covers the summary and test plan, but it omits the required Linear task, objectives details, and the checklist/template sections. | Add the required template sections, especially the Linear task, detailed objectives, and the checklist items, or fill them with N/A where appropriate. |
✅ Passed checks (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | ✅ Passed | The title is concise and accurately summarizes the main change: adding record event dispatch in the batch destination framework. |
| Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Commit unit tests in branch
feat/INT-6653-batch-destination-record-dispatch
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 @coderabbitai help to get the list of available commands.
a620d8f to
c4e8276
Compare
|
Caution Review failedAn error occurred during the review process. Please try again later. Note
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #5324 +/- ##
========================================
Coverage 92.74% 92.74%
========================================
Files 703 704 +1
Lines 38255 38281 +26
Branches 8992 8940 -52
========================================
+ Hits 35479 35505 +26
- Misses 2548 2566 +18
+ Partials 228 210 -18 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
9794692 to
9f37cca
Compare
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
… schema cache Annotate customerio's transform-method parameters inline with `z.infer<typeof recordInputSchema>` / `z.infer<typeof eventStreamInputSchema>` instead of separate named aliases, so it is unmistakable the types are the schema and cannot drift; remove the now-unused aliases. Drop `cachedInputSchema` from VDMV2ObjectDestination: getInputSchema is called once per instance, and an eagerly-computed field cannot work anyway since the subclass's recordSchema/eventStreamSchema initialize after the base. Build the union directly. Codify the inline-`z.infer` convention in the vdm-v2-object-destination skill. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
9f37cca to
b2ac46e
Compare
Remove the "memoizes the schema" test — getInputSchema no longer caches its result (the union is built once per instance), so reference equality across calls is no longer guaranteed. Type the unionInput test helper's return as RouterTransformationRequestData so the four validateInputs call sites no longer need `as any`; the single cast is localized to where the deliberately-malformed envelope is produced. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
68df4ff to
d568317
Compare
The suite imported RecordInput from the framework, which a prior review comment made module-local, so tsc failed to run the test (TS2459) and CI went red. Declare the record envelope type locally in the test instead. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|



Summary
makeRouterInputSchemais now a single-variant builder. It takes onemessageschema plus an optionaldestinationConfig(→destination.Config) and optionalconnectionConfig(→connection.config). The previous multi-variantvariants: [...]API — which built az.unioninternally and validateddestinationConfigoutside the union — has been removed. All existing batching destinations (posthog, custom_audience, google_adwords_enhanced_conversions, iterable_audience) are migrated to the flat shape.VDMV2ObjectDestination. Hybrid (record + event-stream) destinations declare two schemas —recordSchemaandeventStreamSchema, each built viamakeRouterInputSchemawith the shareddestinationConfig— and the framework unions them ingetInputSchema(). Record events validate the connection config (requiresobject); event-stream events don't, so the record schema is never wrongly applied to them.VDMV2ObjectDestination, an object-based record-dispatch layer on top ofBatchDestination:transformObjectRecord(input)returns a handler map of object type → action → handler for record events;transformEventStream(input)returns a message type → handler map for event-stream events.buildRecordEvent).TConnectionConfigto{ destination: { object: string } }so object-type access is type-checked, movesMappedToDestinationpre-processing into the framework, and usesConfigurationErrorfor framework-level validation.VDMV2ObjectDestinationwith record + event-stream support. Transform-method parameters are typed inline withz.infer<typeof recordInputSchema>/z.infer<typeof eventStreamInputSchema>so the types are unmistakably schema-derived and cannot drift.vdm-v2-object-destinationskill.Test plan
makeRouterInputSchema(single-variant) and the union built byVDMV2ObjectDestinationbuildRecordEvent🤖 Generated with Claude Code