Skip to content

feat(versioning): carry integration major on Destination + dev-only test_destination - #5318

Merged
saikumarrs merged 6 commits into
developfrom
feature/int-6495-rudder-transformer-version-on-destination-type-dispatch
Jun 26, 2026
Merged

saikumarrs merged 6 commits into
developfrom
feature/int-6495-rudder-transformer-version-on-destination-type-dispatch

Conversation

@saikumarrs

@saikumarrs saikumarrs commented Jun 25, 2026 •

Copy link
Copy Markdown
Member

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 Destination type + dispatch idiom

  • version?: number on the Destination type (mirrors Go DestinationT.Version). Optional because it can be undefined — 0 / undefined / 1 all dispatch as v1 (Number(undefined) is NaN), so existing destinations behave identically.
  • destinationVersion?: number received on the proxy/dataDelivery payload (ProxyV0/V1Request + zod schemas) — the proxy route carries no destination object, so the major arrives as a sibling field.
  • Dispatch idiom documented in CONTRIBUTING.md and the code-structure Claude skill (in-file branch by default; sibling-module escalation; never route majors through getDestHandler).

INT-6492 — dev-only test_destination (v1 only)

  • src/v0/destinations/test_destination/ dispatches on Number(destination.version) in transform/processRouterDest and on destinationVersion in networkHandler; major >= 2 throws not-implemented (only v1 is built).
  • Processor / router / dataDelivery integration fixtures (v1, no-version, v2-rejection) + a co-located unit test.
  • Router capability registered in features.ts. Clearly labelled "DEV-ONLY — NOT A REAL DESTINATION"; uses the reserved .invalid endpoint. Control-plane exposure is gated to dev only (other repos).

Out of scope

  • No real per-major branch for any production destination (rollout milestone).
  • test_destination v2 path — stubbed to throw; only v1 implemented.

Testing

  • test_destination unit 4/4 · component (processor/router/dataDelivery) 7/7
  • webhook smoke 23/23 · misc (getFeatures) 2/2 — no regression
  • Full pre-commit suite (test:ts + test:js + lint) green.

References

…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
@coderabbitai

coderabbitai Bot commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

.coderabbit.yaml has unrecognized properties

CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.

⚠️ Parsing warnings (1)
Validation error: Unrecognized key: "auto_resolve_threads"
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a59a0883-33a2-44a8-8934-a5295b591226

📥 Commits

Reviewing files that changed from the base of the PR and between cb10b1b and e60c08c.

⛔ Files ignored due to path filters (3)
  • CONTRIBUTING.md is excluded by !**/*.md
  • test/integrations/destinations/test_destination/common.ts is excluded by !**/test/**
  • test/integrations/destinations/test_destination/router/data.ts is excluded by !**/test/**
📒 Files selected for processing (7)
  • src/constants/batchedDestinationsMap.ts
  • src/features.ts
  • src/v0/destinations/test_destination/routerTransform.test.ts
  • src/v0/destinations/test_destination/routerTransform.ts
  • src/v0/destinations/test_destination/transform.test.ts
  • src/v0/destinations/test_destination/transform.ts
  • src/v0/destinations/test_destination/type.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/v0/destinations/test_destination/transform.test.ts
  • src/v0/destinations/test_destination/type.ts

Summary by CodeRabbit

  • New Features

    • Added support for a test destination with version-aware handling.
    • Enabled batching for compatible requests, including combined delivery for multiple events.
    • Added support for carrying destination version information through request payloads.
  • Bug Fixes

    • Normalized destination version values so missing, invalid, or fractional inputs fall back to a supported major version.
    • Added clearer handling when a newer destination version is requested but not yet supported.

Walkthrough

The PR adds a dev-only test destination fixture, extends shared versioned request contracts, normalizes destination major versions, and wires transform, batching, and network dispatch to route v1 requests while rejecting v2 paths.

Changes

Test destination versioning and batching

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
Loading

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@saikumarrs

Copy link
Copy Markdown
Member Author

Stacked follow-up (metric label, INT-6576): #5319 — review/merge this one first.

@codecov

codecov Bot commented Jun 25, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.70%. Comparing base (94f2ec7) to head (e60c08c).
⚠️ Report is 2 commits behind head on develop.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…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
@saikumarrs

Copy link
Copy Markdown
Member Author

Pushed cb10b1b95 — addressed code-review findings on the integration-major dispatch:

  • getDestinationVersion truncates to a whole integer (Math.trunc) so a fractional major can't leak to metrics or mis-route; added float test cases.
  • TEST_DESTINATION gated out of the prod /features payload (NODE_ENV) rather than relying solely on control-plane gating.
  • networkHandler composes on the generic handler and overrides only proxy (drops the verbatim copy, so shared response-contract changes reach the fixture).
  • Dropped the forked TestDestinationResponseParams type + unused import.
  • Shared V2_MAJOR from config.ts across transform/networkHandler.
  • Renamed process → transformEvent (exported as process) to stop shadowing the Node global.
  • Deduped fixtures via v1RequestShape + v2StatTags helpers in common.ts.
  • Docs (CONTRIBUTING + code-structure SKILL) now branch via getDestinationVersion, not bare Number(...), so the normalization isn't bypassed.

Verified on Node 22.22.3 (.nvmrc): lint clean, tsc --noEmit 0 errors, full pre-commit suite green (component + 2334 unit tests).

@saikumarrs
saikumarrs marked this pull request as ready for review June 26, 2026 09:11
@saikumarrs
saikumarrs requested review from a team as code owners June 26, 2026 09:11
…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 shekhar-rudder left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 shekhar-rudder left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/constants/batchedDestinationsMap.ts Resolved
Comment thread src/features.ts Resolved
Comment thread CONTRIBUTING.md Resolved
…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
@sonarqubecloud

Copy link
Copy Markdown

@saikumarrs
saikumarrs merged commit ec450b8 into develop Jun 26, 2026
34 checks passed
@saikumarrs
saikumarrs deleted the feature/int-6495-rudder-transformer-version-on-destination-type-dispatch branch June 26, 2026 12:33
saikumarrs added a commit that referenced this pull request Jun 26, 2026
…#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`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants