Repository navigation
feat(versioning): carry integration major on Destination + dev-only test_destination - #5318
Conversation
…est_destination INT-6495 — version on the Destination type + dispatch idiom: - add `version?: number` to the Destination type (mirrors Go DestinationT.Version; optional since it can be undefined — 0/undefined/1 all dispatch as v1). - add `destinationVersion?: number` to the proxy/dataDelivery request types + zod schemas (the proxy route carries no destination object). - document the in-file dispatch idiom in CONTRIBUTING.md + the code-structure skill. INT-6492 — dev-only test_destination (v1 only): - new src/v0/destinations/test_destination dispatching on Number(destination.version) in transform and on destinationVersion in networkHandler; major >= 2 throws not-implemented. processor/router/dataDelivery + unit tests. - register its router capability in features.ts. Clearly labelled dev-only fixture. The `destVersion` per-destination metric label is split into a stacked follow-up (INT-6576). Pairs with rudderlabs/rudder-server#7125 (carries version on DestinationT). Scanned-by: gitleaks 8.30.0
|
Note
|
| Layer / File(s) | Summary |
|---|---|
Shared contracts src/features.ts, src/types/controlPlaneConfig.ts, src/types/destinationTransformation.ts, src/types/zodTypes.ts |
A dev-only TEST_DESTINATION routerTransform flag is added, and destination/proxy payload types and schemas accept optional version fields. |
Version normalization src/util/utils.js, src/util/utils.test.js |
getDestinationVersion normalizes destination major version inputs and is covered by table-driven tests. |
Fixture types and request builder src/v0/destinations/test_destination/type.ts, src/v0/destinations/test_destination/config.ts, src/v0/destinations/test_destination/utils.ts |
The test destination declares its v1 config and request aliases, exports V2_MAJOR and a v1 endpoint builder, and builds POST request configs from the event payload and optional API key. |
Transform dispatch src/v0/destinations/test_destination/transform.ts, src/v0/destinations/test_destination/transform.test.ts |
process routes destination versions below V2_MAJOR to processV1, throws ConfigurationError for v2, and tests cover the v1 and v2 paths. |
Batching router integration src/constants/batchedDestinationsMap.ts, src/v0/destinations/test_destination/routerTransform.ts, src/v0/destinations/test_destination/routerTransform.test.ts |
TEST_DESTINATION is enabled in batching, and the router transform batches v1 requests while rejecting v2 requests; tests cover the transform shape, batch strategy, batching behavior, and unsupported v2 handling. |
Network proxy dispatch src/v0/destinations/test_destination/networkHandler.ts |
The test destination network handler wraps genericNetworkHandler, installs a proxy that rejects v2 deliveries, and otherwise forwards requests through proxyRequest. |
Sequence Diagram(s)
sequenceDiagram
participant Integration
participant transformEvent
participant getDestinationVersion
participant processV1
participant ChunkBatchStrategy
Integration->>transformEvent: transform each router request
transformEvent->>getDestinationVersion: normalize destination.version
getDestinationVersion-->>transformEvent: major version
alt major < V2_MAJOR
transformEvent->>processV1: build v1 request
processV1-->>transformEvent: request config
Integration->>ChunkBatchStrategy: batch compatible requests
else major >= V2_MAJOR
transformEvent-->>Integration: throw ConfigurationError
end
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~45 minutes
Suggested reviewers
- krishna2020
- shekhar-rudder
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | ✅ Passed | The title is concise and accurately summarizes the main change: versioning support plus the dev-only test destination. |
| Description check | ✅ Passed | The description covers the main changes, objectives, testing, and out-of-scope notes, though it does not fully match the template headings. |
| Docstring Coverage | ✅ Passed | Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. |
| 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 docstrings
- Create stacked PR
- Commit on current branch
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Commit unit tests in branch
feature/int-6495-rudder-transformer-version-on-destination-type-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.
|
Stacked follow-up (metric label, INT-6576): #5319 — review/merge this one first. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #5318 +/- ##
========================================
Coverage 92.69% 92.70%
========================================
Files 700 700
Lines 37937 37970 +33
Branches 8897 8904 +7
========================================
+ Hits 35167 35199 +32
+ Misses 2560 2543 -17
- Partials 210 228 +18 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…zation INT-6495 — centralize the "0 / undefined / non-numeric -> 1" integration-major rule in a shared getDestinationVersion(version) helper (beside getIntegrationVersion in util/utils), so dispatch sites and the per-destination metrics never branch on, or report, a bogus 0. The control plane sends version 0 when the workspace config has no version stamped, and the field is absent on routes that don't carry it. - add getDestinationVersion to src/util/utils.js + unit tests. - use it in test_destination transform + networkHandler dispatch (behavior unchanged). Scanned-by: gitleaks 8.30.0
- getDestinationVersion truncates to a whole integer (Math.trunc) so a fractional major can't leak to metrics or mis-route; add float cases - gate the dev-only TEST_DESTINATION feature flag out of the prod /features payload (NODE_ENV) instead of relying solely on control-plane gating - networkHandler composes on the generic handler and overrides only proxy, so shared response/contract changes reach the fixture (drops the verbatim copy) - drop the forked TestDestinationResponseParams type + unused import - share V2_MAJOR from config.ts across transform/networkHandler - rename process -> transformEvent (exported as process) to stop shadowing the Node.js global - dedupe test fixtures: v1RequestShape + v2StatTags helpers in common.ts - docs (CONTRIBUTING.md, code-structure SKILL): branch via getDestinationVersion, not bare Number(...), so the normalization isn't bypassed Scanned-by: gitleaks 8.30.0
|
Pushed
Verified on Node 22.22.3 ( |
…g framework Per review on #5318: even though batching isn't required for this dummy destination, wire its router transform through the native batching framework as a worked reference for the recommended pattern. - add routerTransform.ts: BatchDestination subclass that reuses the version-dispatching per-event `process` and wraps payloads under `batch` - register TEST_DESTINATION in batchedDestinationsMap (dev-only; gated out of prod at features.ts) - TestDestinationV1Config becomes a type alias so it carries an implicit index signature (required by the framework's RouterTransformationRequestData) - add routerTransform.test.ts (via processBatchedDestination) and update the router component fixture to the batched output shape Scanned-by: gitleaks 8.30.0
shekhar-rudder
left a comment
There was a problem hiding this comment.
Clean, well-tested change — the version dispatch, getDestinationVersion normalization, batching-framework integration, and network-handler composition all check out, and the test fixtures match the code. A few minor notes below: one dead-code cleanup in the dev fixture and two stale comments that describe the bare-Number() dispatch the PR's own docs warn against.
…ispatch comments Address review on #5318: - remove processRouterDest + the simpleProcessRouterDest import: test_destination is batching-GA, so the router always runs through routerTransform.ts and the legacy path is unreachable. The module now exports only the per-event `process`. - reword two stale comments (transform.test.ts, common.ts) that described the old bare `Number(...) < 2` dispatch to reference getDestinationVersion normalization. Scanned-by: gitleaks 8.30.0
shekhar-rudder
left a comment
There was a problem hiding this comment.
A few follow-ups: consolidate the repeated dev-only note, the NODE_ENV gating in features.ts is likely unnecessary, and one CONTRIBUTING.md line went stale after dropping processRouterDest.
…note, fix stale refs Address review follow-ups on #5318: - features.ts: drop the process.env.NODE_ENV gate — the /features payload is informational, exposure is governed by control-plane workspace config, so the gate added complexity without preventing processing. Back to plain TEST_DESTINATION: true. - consolidate the dev-only/INT-6492 note: config.ts stays canonical; features.ts and batchedDestinationsMap.ts now carry a short pointer to it. - CONTRIBUTING.md: drop processRouterDest from the worked-example list (removed last commit; router now runs through the batching framework). - common.ts: v1RequestShape comment no longer claims the router fixture uses it (it now asserts the batched-request shape). Scanned-by: gitleaks 8.30.0
|
…#5319) ## What Low-cardinality observability follow-up (INT-6576) — emit the integration major as a `destVersion` label on the per-destination transform metrics, so adoption / per-version error & latency / retirement-readiness are sliceable by major. Label-wiring only, no data-path change. - `destVersion` label on `dest_transform_input_events` + `dest_transform_output_events` (processor + router paths), read from `events[0]?.destination?.version`. - Registered in the prometheus labelset (`src/util/prometheus.js`) — prom-client rejects labels absent from a metric's initial labelset. ## Scope Scoped to the two transform-event histograms (where `destination.version` is in scope in the controller). The other candidates were deliberately left out: `event_transform_success`/`failure` and `outgoing_request_*` need cross-cutting threading through `getTags`/`MetaTransferObject`/`network.js`; `tf_proxy_*`, `transformer_proxy_*`, `dest_transform_requests`, and `v0_transformation_time` are defined but never emitted. ## Stacked on Built on top of **#5318** ([INT-6495](https://linear.app/rudderstack/issue/INT-6495) — `version?` on the `Destination` type). Base branch is that PR's branch; this metric reads the field it adds. **Review/merge #5318 first.** ## Testing - `test_destination` component run: histograms emit with `destVersion`; prom-client raises no "label not in initial labelset" error. `webhook` smoke 23/23 (no regression). - Full pre-commit suite (`test:ts` + `test:js` + lint) green. ## References - Linear: [INT-6576](https://linear.app/rudderstack/issue/INT-6576) — `version` metric label on per-destination metrics. - Stacked on: #5318 ([INT-6495](https://linear.app/rudderstack/issue/INT-6495) / [INT-6492](https://linear.app/rudderstack/issue/INT-6492)). - Data source: rudderlabs/rudder-server#7125 — provides `destination.version`.



What
The data-plane half of integration definition-versioning in the transformer — carry the integration major on the destination and dispatch on it, plus a dev-only destination that exercises it end-to-end. No production destination grows a real per-major branch here.
INT-6495 — version on the
Destinationtype + dispatch idiomversion?: numberon theDestinationtype (mirrors GoDestinationT.Version). Optional because it can be undefined —0/undefined/1all dispatch as v1 (Number(undefined)isNaN), so existing destinations behave identically.destinationVersion?: numberreceived on the proxy/dataDelivery payload (ProxyV0/V1Request+ zod schemas) — the proxy route carries no destination object, so the major arrives as a sibling field.CONTRIBUTING.mdand thecode-structureClaude skill (in-file branch by default; sibling-module escalation; never route majors throughgetDestHandler).INT-6492 — dev-only
test_destination(v1 only)src/v0/destinations/test_destination/dispatches onNumber(destination.version)intransform/processRouterDestand ondestinationVersioninnetworkHandler;major >= 2throws not-implemented (only v1 is built).features.ts. Clearly labelled "DEV-ONLY — NOT A REAL DESTINATION"; uses the reserved.invalidendpoint. Control-plane exposure is gated to dev only (other repos).Out of scope
test_destinationv2 path — stubbed to throw; only v1 implemented.Testing
test_destinationunit 4/4 · component (processor/router/dataDelivery) 7/7webhooksmoke 23/23 ·misc(getFeatures) 2/2 — no regressiontest:ts+test:js+ lint) green.References
Destinationtype + dispatch idiom) · INT-6492 (dev-onlytest_destination)versiononDestinationT; sendsdestination.version(transform/router) + top-leveldestinationVersion(proxy).destVersionmetric label.