Skip to content

feat: implement rudder-test destination with migrated tests - #4352

Merged
koladilip merged 2 commits into
developfrom
chore/rudder-test-dest
Jun 2, 2025
Merged

koladilip merged 2 commits into
developfrom
chore/rudder-test-dest

Conversation

@koladilip

@koladilip koladilip commented May 26, 2025 •

Copy link
Copy Markdown
Contributor

Summary

This PR implements a new rudder-test destination designed for platform testing and development, along with migrated tests following the new test format.

What's New

🎯 Rudder Test Destination

  • Purpose: Special testing destination for platform development without external dependencies
  • Architecture: Router-only transformation with TypeScript implementation
  • Event Support: Record v2 events only (insert, update, delete operations)
  • Echo Pattern: Returns processed event data for verification
  • Controlled Testing: Programmable responses via context.testBehavior

🧪 Test Implementation

  • Migrated Tests: Used migration script to convert to new test format
  • Optimized Structure: Reduced duplication using generateMetadata utility
  • Enhanced Validation: Enabled Zod schema validation and Allure reporting
  • Type Safety: Proper TypeScript typing throughout

🛠️ Developer Experience

  • NPM Script: Added npm run test:ts:component:rudder_test for convenient test execution
  • Documentation: Comprehensive README.md section with usage examples
  • Reference Implementation: Demonstrates proper RudderStack destination patterns

Key Features

Context-Based Test Control

{
  "context": {
    "testBehavior": {
      "statusCode": 400,
      "errorMessage": "Custom test error"
    }
  }
}

Use Cases

  • ✅ Platform feature testing without external services
  • ✅ Development workflow validation
  • ✅ CI/CD reliability (no external dependencies)
  • ✅ Learning and debugging RudderStack transformations
  • ✅ Integration testing for event processing pipelines

Files Added

Destination Implementation

  • src/v0/destinations/rudder_test/transform.ts - Main transformation logic
  • src/v0/destinations/rudder_test/type.ts - TypeScript type definitions
  • src/v0/destinations/rudder_test/config.ts - Basic configuration

Test Infrastructure

  • test/integrations/destinations/rudder_test/common.ts - Shared test utilities
  • test/integrations/destinations/rudder_test/router/data.ts - Router test cases

Documentation

  • RUDDER_TEST_DESTINATION_PLAN.md - Implementation plan and architecture
  • INTEGRATION_TEST_PLAN.md - Testing strategy and validation
  • Updated README.md with comprehensive destination documentation

Files Modified

  • package.json - Added rudder-tests npm script
  • test/integrations/component.test.ts - Added to INTEGRATIONS_WITH_UPDATED_TEST_STRUCTURE

Testing

✅ All tests pass (2/2 router tests)
✅ Zod validation enabled
✅ Enhanced Allure reporting active
✅ Pre-commit hooks pass (TypeScript + JavaScript tests + linting)
✅ Test migration completed successfully

Usage

# Run rudder-test destination tests
npm run rudder-tests

# Run specific test by index
npm run test:ts -- component --destination=rudder_test --index=0

Implementation Highlights

  • Minimal Dependencies: Self-contained with no external API requirements
  • Standard Architecture: Follows RudderStack destination patterns
  • Error Handling: Proper error responses with statTags
  • Type Safety: Full TypeScript implementation with proper typing
  • Test Format: Follows new test structure with utility functions

Benefits

  1. Reliable Testing: No external service dependencies
  2. Fast Development: Quick validation during development
  3. Learning Tool: Understand RudderStack transformation pipeline
  4. Reference Implementation: Example of proper destination architecture
  5. Platform Testing: Validate new features without setup complexity

This destination provides a controlled, predictable environment for testing RudderStack's transformation pipeline and serves as an excellent reference for destination development.


Resolves INT-3620
Pull Request opened by Augment Code with guidance from the PR author

@koladilip
koladilip requested review from a team and sivashanmukh as code owners May 26, 2025 16:46
@koladilip
koladilip requested review from a team, manish339k and yashasvibajpai May 26, 2025 16:46
@coderabbitai

coderabbitai Bot commented May 26, 2025 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • test/integrations/component.test.ts is excluded by !**/test/**

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Summary by CodeRabbit

  • New Features
    • Introduced support for a new "RudderTest" destination, including configuration options and type definitions.
    • Added processing logic for both single and batched test events, with custom behavior based on test parameters.
    • Implemented enhanced error handling and response formatting for test scenarios.

Walkthrough

This change introduces a new "rudder_test" destination module with configuration, type definitions, transformation logic, and utility functions. The implementation supports test behaviors for simulating response codes and errors, processes both single and batched events, and structures responses accordingly. All components are modularized for clarity and reuse.

Changes

File(s) Change Summary
src/v0/destinations/rudder_test/config.ts Added a configuration file exporting the BASE_ENDPOINT constant for the test destination.
src/v0/destinations/rudder_test/transform.ts Implemented processRouterDest and process functions for handling batched and single event transformations.
src/v0/destinations/rudder_test/type.ts Defined TypeScript interfaces and types for test behaviors, messages, configs, requests, and responses.
src/v0/destinations/rudder_test/utils.ts Added utility functions for message validation, payload building, test behavior handling, and error responses.

Sequence Diagram(s)

sequenceDiagram
    participant Source as Event Source
    participant Transform as transform.ts
    participant Utils as utils.ts
    participant Config as config.ts

    Source->>Transform: processRouterDest(events, metadata)
    alt events is empty
        Transform-->>Source: []
    else For each event
        Transform->>Utils: validateMessageType(event)
        Transform->>Utils: hasTestBehaviorError(event)
        alt Test behavior error present
            Transform->>Utils: buildTestBehaviorErrorResponse(event, metadata, destination)
            Utils-->>Transform: Error response
            Transform-->>Source: Error response
        else
            Transform->>Utils: buildRequestConfig(event, destination)
            Utils-->>Transform: Request config
            Transform-->>Source: Success response with request config
        end
    end
Loading

Suggested reviewers

  • sivashanmukh
  • krishna2020
  • manish339k
  • yashasvibajpai

Suggestions for improvement:

  • Consider adding unit tests for the new utility and transformation functions to ensure robust error handling and correct test behavior simulation.
  • Document the intended use cases for the testBehavior field more thoroughly, possibly with example payloads.
  • Evaluate if the error response structure aligns with existing conventions in other destinations for consistency.

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/v0/destinations/rudder_test/transform.ts (2)

27-43: Test behavior implementation provides flexible error simulation.

The test behavior logic allows controlled error responses for testing scenarios. The error response structure includes proper metadata and standardized stat tags for monitoring.

Consider extracting the stat tags to a constant for consistency:

+const ERROR_STAT_TAGS = {
+  destType: 'rudder_test',
+  errorCategory: 'dataValidation',
+  errorType: 'instrumentation',
+  feature: 'router',
+  implementation: 'native',
+  module: 'destination',
+};

-          statTags: {
-            destType: 'rudder_test',
-            errorCategory: 'dataValidation',
-            errorType: 'instrumentation',
-            feature: 'router',
-            implementation: 'native',
-            module: 'destination',
-          },
+          statTags: ERROR_STAT_TAGS,

62-66: Consider optimizing empty object structures.

The response body includes several empty objects (JSON_ARRAY, XML, FORM) that may not be necessary for this test destination. Consider omitting unused fields to reduce payload size.

          body: {
            JSON: {
              action: event.message.action,
              fields: event.message.fields || {},
              identifiers: event.message.identifiers || {},
              recordId: event.message.recordId,
              timestamp: event.message.timestamp || new Date().toISOString(),
            },
-            JSON_ARRAY: {},
-            XML: {},
-            FORM: {},
          },
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f3636e9 and 561005173bd78f9341b6babde70d96d5667dd063.

⛔ Files ignored due to path filters (11)
  • Add event request retry headers in SDKs 1b2f2b415dd08068bd5acbc9e14572c0.md is excluded by !**/*.md
  • INTEGRATION_TEST_PLAN.md is excluded by !**/*.md
  • README.md is excluded by !**/*.md
  • RUDDER_TEST_DESTINATION_PLAN.md is excluded by !**/*.md
  • package.json is excluded by !**/*.json
  • test/integrations/component.test.ts is excluded by !**/test/**
  • test/integrations/destinations/customerio_audience/router/data.ts is excluded by !**/test/**
  • test/integrations/destinations/rudder_test/common.ts is excluded by !**/test/**
  • test/integrations/destinations/rudder_test/router/data.ts is excluded by !**/test/**
  • test/integrations/ensureMessageId.ts is excluded by !**/test/**
  • updated_pr_description.md is excluded by !**/*.md
📒 Files selected for processing (4)
  • src/types/rudderEvents.ts (1 hunks)
  • src/v0/destinations/rudder_test/config.ts (1 hunks)
  • src/v0/destinations/rudder_test/transform.ts (1 hunks)
  • src/v0/destinations/rudder_test/type.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/v0/destinations/rudder_test/type.ts (4)
src/types/rudderEvents.ts (2)
  • RudderRecordV2 (80-80)
  • Metadata (121-121)
src/types/controlPlaneConfig.ts (1)
  • Destination (29-46)
src/types/destinationTransformation.ts (2)
  • RouterTransformationRequestData (89-100)
  • ProcessorTransformationOutput (66-76)
src/v0/destinations/intercom_v2/config.js (1)
  • RecordAction (9-13)
src/v0/destinations/rudder_test/transform.ts (3)
src/v0/destinations/rudder_test/type.ts (1)
  • RudderTestRouterRequest (26-31)
src/v0/destinations/rudder_test/config.ts (1)
  • BASE_ENDPOINT (1-1)
src/v0/util/index.js (1)
  • handleRtTfSingleEventError (1778-1795)
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image AMD64
  • GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image ARM64
  • GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image ARM64
  • GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image AMD64
  • GitHub Check: Code Coverage
  • GitHub Check: test_and_publish
  • GitHub Check: UT Tests
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (go)
🔇 Additional comments (12)
src/v0/destinations/rudder_test/config.ts (1)

1-1: Configuration looks good and follows minimalist design.

The BASE_ENDPOINT configuration is appropriately set for a test destination. The URL structure follows REST conventions and the test domain is suitable for development/testing purposes.

src/v0/destinations/rudder_test/transform.ts (4)

6-11: Good defensive programming with input validation.

The function properly handles edge cases by returning an empty array when no inputs are provided, which prevents unnecessary processing and potential errors.


17-21: Message type validation is appropriate for the destination's scope.

The validation ensures only 'record' type messages are processed, which aligns with the destination's intended purpose. The error message is clear and informative.


46-72: Response construction follows proper batched request format.

The success response structure correctly implements the expected batched request format with appropriate headers, endpoint, and body structure. The timestamp defaulting logic ensures consistent data.


73-76: Proper error handling delegation.

The catch block appropriately delegates to the existing error handling utility, maintaining consistency with the broader codebase's error handling patterns.

src/v0/destinations/rudder_test/type.ts (7)

1-8: Well-organized imports with proper type dependencies.

The imports are logically grouped and include all necessary types from the broader type system. The import structure supports the type definitions below.


11-14: TestBehavior interface provides clear test control.

The interface design is simple and focused, allowing users to specify status codes and optional error messages for testing scenarios. This aligns well with the transformation logic.


17-21: Message type extension follows proper TypeScript patterns.

The type correctly extends RudderRecordV2 while preserving the existing context structure and adding the optional testBehavior field. The intersection type approach is appropriate here.


23-23: Destination type correctly represents minimal configuration.

Using Record<string, never> for the configuration type accurately represents that this destination requires no configuration parameters, which aligns with its test-focused design.


26-31: Router request type properly parameterized.

The RouterTransformationRequestData is correctly parameterized with the custom message and destination types, with undefined for connection reflecting the stateless nature of this test destination.


34-40: Response payload interface accurately models echo behavior.

The interface correctly represents the data structure that will be echoed back, including all necessary fields from the record event. The types align with the transformation logic implementation.


43-47: Response type extension maintains compatibility.

The type properly extends the existing ProcessorTransformationOutput while adding the specific JSON body structure for this destination's responses.

Comment thread src/types/rudderEvents.ts Resolved
@koladilip
koladilip force-pushed the chore/rudder-test-dest branch 2 times, most recently from d353d4c to 75a543c Compare May 26, 2025 16:51
@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@codecov

codecov Bot commented May 26, 2025 •

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.13%. Comparing base (c684b65) to head (ab17a31).
Report is 8 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4352      +/-   ##
===========================================
+ Coverage    91.12%   91.13%   +0.01%     
===========================================
  Files          636      638       +2     
  Lines        33400    33449      +49     
  Branches      7896     7889       -7     
===========================================
+ Hits         30435    30483      +48     
- Misses        2696     2727      +31     
+ Partials       269      239      -30     

☔ View full report in Codecov by Sentry.
📢 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.

@koladilip
koladilip force-pushed the chore/rudder-test-dest branch 2 times, most recently from ba69e2b to cce9063 Compare May 28, 2025 01:30
@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

1 similar comment
@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (4)
src/v0/destinations/rudder_test/utils.ts (4)

14-21: Consider making timestamp generation more explicit.

The payload building logic is solid, but the fallback timestamp generation could be more explicit about timezone handling.

Consider this improvement for better timestamp handling:

-  timestamp: message.timestamp || new Date().toISOString(),
+  timestamp: message.timestamp || new Date().toISOString(),

Alternatively, you might want to document the timezone behavior or consider using a consistent UTC timestamp format.


23-38: Remove unused request body formats to reduce noise.

The request configuration structure includes unused body formats that add unnecessary complexity.

Consider removing unused body format placeholders:

   body: {
     JSON: buildJsonPayload(message),
-    JSON_ARRAY: {},
-    XML: {},
-    FORM: {},
   },

This will make the configuration cleaner and more focused on the actual requirements.


43-47: Refactor boolean conversion for better readability.

The double negation pattern works but could be more explicit for better code readability.

Consider this more explicit approach:

-  return !!(testBehavior?.statusCode && testBehavior.statusCode !== 200);
+  return Boolean(testBehavior?.statusCode && testBehavior.statusCode !== 200);

This makes the boolean conversion intent more explicit.


49-56: Extract common test behavior validation logic.

There's duplication between this function and hasTestBehaviorError that could be reduced.

Consider extracting the common validation logic:

+const isErrorStatusCode = (statusCode?: number): boolean => 
+  Boolean(statusCode && statusCode !== 200);
+
 export const checkTestBehaviorAndThrow = (message: RudderTestMessage): void => {
   const testBehavior = getTestBehavior(message);
 
-  if (testBehavior?.statusCode && testBehavior.statusCode !== 200) {
+  if (isErrorStatusCode(testBehavior?.statusCode)) {
     throw new InstrumentationError(testBehavior.errorMessage || 'Test error');
   }
 };

Then update hasTestBehaviorError to use the same helper function.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cce90635f7eff9bcc1475dc789b7ad105e5edeb0 and 8a149b1e629bdf42a3eb28800677afeae0551327.

⛔ Files ignored due to path filters (4)
  • package.json is excluded by !**/*.json
  • test/integrations/component.test.ts is excluded by !**/test/**
  • test/integrations/destinations/rudder_test/processor/data.ts is excluded by !**/test/**
  • test/integrations/destinations/rudder_test/router/data.ts is excluded by !**/test/**
📒 Files selected for processing (2)
  • src/v0/destinations/rudder_test/transform.ts (1 hunks)
  • src/v0/destinations/rudder_test/utils.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/v0/destinations/rudder_test/transform.ts
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/v0/destinations/rudder_test/utils.ts (1)
src/v0/destinations/rudder_test/type.ts (1)
  • RudderTestMessage (17-21)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: Code Coverage
  • GitHub Check: test_and_publish
  • GitHub Check: UT Tests
  • GitHub Check: Analyze (go)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (3)
src/v0/destinations/rudder_test/utils.ts (3)

1-3: Clean imports and well-structured module setup.

The imports are properly organized and follow TypeScript best practices. Good use of local imports for configuration and types.


5-12: Validate message type function implementation is correct.

The validation logic is straightforward and appropriately throws an InstrumentationError for unsupported message types. The error message is descriptive and helpful for debugging.


40-41: Simple and effective getter function.

Clean implementation using optional chaining. This pattern is consistent and safe.

@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@koladilip
koladilip force-pushed the chore/rudder-test-dest branch from c0d49e0 to 97e46c2 Compare May 29, 2025 14:31
@koladilip
koladilip requested a review from a team as a code owner May 29, 2025 14:31

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/middlewares/routerTransformCompactedPayloadV1.ts (1)

27-27: Excellent security practice with proper placement.

Applying deepFreeze to the destination config is a solid security measure that prevents downstream mutations. The placement after destination validation but before connection processing is appropriate.

Consider documenting this behavior change if destinations previously relied on config mutability, though the immutability should be the expected standard.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c0d49e027cb738541bc0fcfc434cda1070faf03e and 97e46c2e3789c0694e825f80e692ef15f33ee90e.

⛔ Files ignored due to path filters (7)
  • README.md is excluded by !**/*.md
  • package-lock.json is excluded by !**/package-lock.json, !**/*.json
  • package.json is excluded by !**/*.json
  • test/integrations/component.test.ts is excluded by !**/test/**
  • test/integrations/destinations/rudder_test/common.ts is excluded by !**/test/**
  • test/integrations/destinations/rudder_test/processor/data.ts is excluded by !**/test/**
  • test/integrations/destinations/rudder_test/router/data.ts is excluded by !**/test/**
📒 Files selected for processing (7)
  • src/middlewares/destTransformCompactedPayloadV1.ts (2 hunks)
  • src/middlewares/routerTransformCompactedPayloadV1.ts (2 hunks)
  • src/util/dynamicConfigParser.ts (2 hunks)
  • src/v0/destinations/rudder_test/config.ts (1 hunks)
  • src/v0/destinations/rudder_test/transform.ts (1 hunks)
  • src/v0/destinations/rudder_test/type.ts (1 hunks)
  • src/v0/destinations/rudder_test/utils.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/v0/destinations/rudder_test/config.ts
  • src/v0/destinations/rudder_test/transform.ts
  • src/v0/destinations/rudder_test/utils.ts
  • src/v0/destinations/rudder_test/type.ts
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image AMD64
  • GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image ARM64
  • GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image AMD64
  • GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image ARM64
  • GitHub Check: Code Coverage
  • GitHub Check: test_and_publish
  • GitHub Check: UT Tests
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (go)
🔇 Additional comments (6)
src/middlewares/routerTransformCompactedPayloadV1.ts (1)

2-2: Good addition of deepFreeze import for config immutability.

The import change correctly adds the deepFreeze utility to support config immutability enforcement.

src/middlewares/destTransformCompactedPayloadV1.ts (2)

2-2: Consistent import addition for config immutability.

The deepFreeze import aligns with the same change in the router middleware, maintaining consistency across the codebase.


23-23: Proper immutability enforcement with good placement.

The deepFreeze application is correctly placed after destination validation and maintains consistency with the router middleware implementation. This ensures destination configs are immutable throughout the processing pipeline.

src/util/dynamicConfigParser.ts (3)

14-15: Well-designed regex pattern for path validation.

The PATH_VALIDATION_REGEX correctly validates dot-notation paths with appropriate constraints:

  • Starts with letter or underscore
  • Allows word characters in path segments
  • Supports dot-separated segments

This provides good security by preventing injection of invalid path patterns while supporting legitimate use cases like event.context.traits.email.


45-45: Proper integration of path validation.

The regex validation is correctly integrated into the template parsing logic, providing an additional security layer to ensure only valid dot-notation paths are processed.


158-158:

Details

✅ Verification successful

Good modernization to native structuredClone.

Replacing lodash's cloneDeep with native structuredClone is a performance improvement and reduces dependencies. However, ensure compatibility requirements are met since structuredClone requires Node.js 17+ or modern browsers.

Please verify that the runtime environment supports structuredClone:


🏁 Script executed:

#!/bin/bash
# Check Node.js version requirements and structuredClone availability
echo "Checking Node.js version and structuredClone support..."

# Check if package.json specifies Node.js version requirements
if [ -f "package.json" ]; then
  echo "=== package.json engines ==="
  jq '.engines' package.json 2>/dev/null || echo "No engines specified"
fi

# Check if there are any Node.js version files
if [ -f ".nvmrc" ]; then
  echo "=== .nvmrc content ==="
  cat .nvmrc
fi

if [ -f ".node-version" ]; then
  echo "=== .node-version content ==="
  cat .node-version
fi

# Check for any documentation about Node.js requirements
echo "=== Searching for Node.js version documentation ==="
fd -t f "README|CONTRIBUTING|CHANGELOG" | head -5 | xargs rg -i "node.*version|node.*require" 2>/dev/null || echo "No explicit Node.js version documentation found"

Length of output: 1152


structuredClone compatibility confirmed
The project’s .nvmrc pins Node.js to v20.18.3 (≥17.0), so native structuredClone is fully supported.
Approving the replacement of cloneDeep with structuredClone.

@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/v0/destinations/rudder_test/type.ts (1)

40-47: Consider using a more specific type instead of any for fields.

The interface structure is good for echoing back record data, but the fields property uses any which reduces type safety.

Consider replacing any with a more specific type:

-  fields: Record<string, any>;
+  fields: Record<string, unknown>;

Or even better, if the fields structure is known:

-  fields: Record<string, any>;
+  fields: Record<string, string | number | boolean | null>;

This maintains flexibility while providing better type safety and preventing potential runtime issues.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 97e46c2e3789c0694e825f80e692ef15f33ee90e and 400c2bfc62f95d6bc3743ff154acd52d1d07417e.

⛔ Files ignored due to path filters (4)
  • test/integrations/destinations/rudder_test/common.ts is excluded by !**/test/**
  • test/integrations/destinations/rudder_test/processor/data.ts is excluded by !**/test/**
  • test/integrations/destinations/rudder_test/router/data.ts is excluded by !**/test/**
  • test/integrations/testTypes.ts is excluded by !**/test/**
📒 Files selected for processing (3)
  • src/v0/destinations/rudder_test/transform.ts (1 hunks)
  • src/v0/destinations/rudder_test/type.ts (1 hunks)
  • src/v0/destinations/rudder_test/utils.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/v0/destinations/rudder_test/transform.ts
  • src/v0/destinations/rudder_test/utils.ts
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/v0/destinations/rudder_test/type.ts (4)
src/types/rudderEvents.ts (2)
  • RudderRecordV2 (80-80)
  • Metadata (121-121)
src/types/controlPlaneConfig.ts (1)
  • Destination (11-23)
src/types/destinationTransformation.ts (2)
  • RouterTransformationRequestData (89-100)
  • ProcessorTransformationOutput (66-76)
src/v0/destinations/intercom_v2/config.js (1)
  • RecordAction (9-13)
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image AMD64
  • GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image AMD64
  • GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image ARM64
  • GitHub Check: Code Coverage
  • GitHub Check: UT Tests
  • GitHub Check: test_and_publish
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (go)
🔇 Additional comments (6)
src/v0/destinations/rudder_test/type.ts (6)

1-8: LGTM: Clean and well-organized imports.

The import statements are well-structured and all imported types are utilized within the file. The relative path imports are correct for the file structure.


10-14: LGTM: Simple and effective test behavior interface.

The TestBehavior interface provides a clean way to control test responses with a required status code and optional error message, which aligns well with the testing objectives mentioned in the PR.


16-21: LGTM: Proper type extension for test context.

The RudderTestMessage type correctly extends RudderRecordV2 while adding the optional testBehavior to the context. The intersection type usage and optional chaining structure are implemented correctly.


23-28: LGTM: Flexible configuration interface.

The RudderTestConfig interface appropriately makes all fields optional, which is suitable for a test destination that should work with minimal configuration.


30-38: LGTM: Proper generic type usage.

Both RudderTestDestination and RudderTestRouterRequest types correctly utilize generics and follow the established patterns in the codebase. The explicit documentation about not needing a connection is helpful.


49-54: LGTM: Consistent response type structure.

The RudderTestResponse type properly extends ProcessorTransformationOutput and follows the established pattern for response body structure with the optional JSON payload.

@koladilip
koladilip force-pushed the chore/rudder-test-dest branch from 400c2bf to bc8752d Compare May 29, 2025 15:54
@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@koladilip
koladilip force-pushed the chore/rudder-test-dest branch from f6d7aa7 to a8841db Compare May 30, 2025 05:18
@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

Comment thread package.json Resolved
@koladilip
koladilip force-pushed the chore/rudder-test-dest branch from a8841db to c441452 Compare May 30, 2025 10:36
- Add rudder-test destination for platform testing and development
- Implement TypeScript destination with router-only transformation
- Support Record v2 events with echo response pattern
- Add context-based test behavior control via testBehavior field
- Migrate tests to new format using migration script
- Optimize tests with generateMetadata utility and common destination
- Enable Zod validation and enhanced Allure reporting
- Add npm script 'rudder-tests' for convenient test execution
- Update README.md with comprehensive destination documentation

The rudder-test destination provides a controlled testing environment
without external dependencies, ideal for platform feature testing,
development workflows, and CI/CD reliability.

refactor: reduce code duplication in rudder_test destination

- Extract common validation and request building logic to utils.ts
- Add processor transformation function alongside existing router function
- Create comprehensive component tests for both processor and router
- Implement shared utilities for message validation, request config building, and test behavior handling
- Maintain different error handling patterns for processor (throws) vs router (returns error objects)
- Add 6 test cases covering success scenarios, error responses, and validation failures

refactor: improve type safety in rudder_test utils

- Replace 'any' types with specific Metadata and RudderTestDestination types
- Import proper types from '../../../types' for better type safety
- Enhance IntelliSense support and compile-time error detection
- Address coderabbitai bot feedback on PR #4352

feat: enhance rudder_test destination with comprehensive dynamic config testing

- Modified rudder_test destination to actually use resolved dynamic config values
- Added endpoint and apiKey resolution from destination config in utils.ts
- Updated transform.ts to pass destination config to utility functions
- Enhanced type definitions to support RudderTestConfig interface

- Added multi-event test cases for both processor and router
- Tests validate multiple events with different dynamic config values resolve correctly
- Added mixed destination ID scenarios (different hasDynamicConfig flags)
- Added compaction tests with multiple events and dynamic config
- All 20 tests now pass and actually validate dynamic config resolution

These tests will surface thread safety issues and shared state problems
in dynamic config processing by testing scenarios where multiple events
have different template variable values that must resolve independently.

docs: update rudder_test destination documentation with dynamic config features

- Added dynamic config resolution capabilities to feature list
- Updated implementation details to reflect both processor and router support
- Added comprehensive test coverage information (20 test cases)
- Included dynamic config examples with template syntax
- Added multi-event testing and thread safety testing use cases
- Updated key files list to include utils.ts and enhanced type definitions
- Corrected architecture description from router-only to dual implementation
@koladilip
koladilip force-pushed the chore/rudder-test-dest branch from c441452 to c6c2958 Compare May 30, 2025 10:39
@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

vinayteki95
vinayteki95 previously approved these changes May 30, 2025
@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@sonarqubecloud

Copy link
Copy Markdown

@koladilip
koladilip merged commit c535626 into develop Jun 2, 2025
@koladilip
koladilip deleted the chore/rudder-test-dest branch June 2, 2025 05:09
koladilip added a commit that referenced this pull request Jun 30, 2025
* fix: handle empty oauth secret for multiple destination (#4295)

* fix: handle empty oauth secret for multiple destination

* fix: test

* fix: add validation for other field

* chore: add missing test

* chore: add more test

* chore: change test

* chore: misc

* feat: implement hasDynamicConfig flag support (#4321)

* feat: implement hasDynamicConfig flag support in routerTransform flow

This implements support for the hasDynamicConfig flag in the routerTransform flow to fix
the issue where events with dynamic configuration were being mixed up during transformation.
The implementation includes:

1. Added a new hasDynamicConfig flag to the Destination type in controlPlaneConfig.ts to indicate
 whether a destination's configuration contains dynamic config patterns
2. Modified the dynamicConfigParser.ts to respect the hasDynamicConfig flag:
   - Skip processing when hasDynamicConfig is explicitly false
   - Process events when hasDynamicConfig is true or undefined (for backward compatibility)
3. Enhanced groupRouterTransformEvents function in src/v0/util/index.js to:
   - Group events by destination config when hasDynamicConfig is true or undefined
   - Use fast-json-stable-stringify to ensure consistent grouping of configs with different key orders
   - Maintain backward compatibility with older server versions where the flag might not be present
4. Added comprehensive test cases for:
   - Testing behavior with hasDynamicConfig=false
   - Testing behavior with hasDynamicConfig=true
   - Testing backward compatibility with hasDynamicConfig=undefined
   - Testing mixed hasDynamicConfig flags in a batch
   - Testing configs with different key orders

This implementation resolves INT-3633 by ensuring that events with dynamic configuration are properly
 grouped and processed in the routerTransform flow, preventing event mix-up issues.

Dependencies:
- Added fast-json-stable-stringify package to ensure consistent JSON string representation regardless of key order

* fix: add hasDynamicConfig flag support in routerTransform flow

* test: add hasDynamicConfig flag to test files

fix tests

* refactor: optimize dynamicConfigParser to avoid deep cloning entire event

* fix: restore unset functionality in dynamic config parser

- Add unset-value import to properly remove extracted fields from events
- Restore unset() call after extracting dynamic config values to prevent downstream issues
- Change from shallow to deep cloning to avoid modifying original events during unset operations
- Add comprehensive test to verify unset functionality works correctly
- Add shouldGroupByDestinationConfig method to JavaScript dynamic config module
- Update groupRouterTransformEvents to use shouldGroupByDestinationConfig function
- Add environment variable tests for USE_HAS_DYNAMIC_CONFIG_FLAG in router grouping logic

This ensures that fields used in dynamic config templates (e.g., {{ message.traits.appId || 'default' }})
are properly removed from events after extraction, preventing potential conflicts in destination processing.

* refactor: optimize dynamic config parser and consolidate utilities

- Move utility functions from dynamicConfig.js to utils.js for better organization
- Optimize DynamicConfigParser with pre-compiled regex patterns and efficient loops
- Replace deep cloning with selective cloning for better performance
- Remove standalone dynamicConfig.js and dynamicConfig.test.js files
- Update imports and references across affected modules

* fix: ensure consistent ordering in batch processing for google adwords offline conversions (#4359)

- Add sorting by jobId to removeDuplicateMetadata function
- Sort final batch results by minimum jobId for consistent ordering
- Re-enable router output assertion for google_adwords_offline_conversions tests
- Update test data ordering to match new consistent batch processing behavior
- Fix unit test expectations to match new sorted metadata order

* chore: add concurrent requests and memory fencing middlewares (#4358)

* chore: migrate tiktok_ads to new test (#4342)

* chore: migrate tiktok_ads to new test

* chore: review comments

* chore: review comments

* chore: review comments

* chore: review comments

* chore: rebase

* chore: introduce deep freeze to compaction middlewares (#4365)

* feat: implement rudder-test destination with migrated tests (#4352)

- Add rudder-test destination for platform testing and development
- Implement TypeScript destination with router-only transformation
- Support Record v2 events with echo response pattern
- Add context-based test behavior control via testBehavior field
- Migrate tests to new format using migration script
- Optimize tests with generateMetadata utility and common destination
- Enable Zod validation and enhanced Allure reporting
- Add npm script 'rudder-tests' for convenient test execution
- Update README.md with comprehensive destination documentation

The rudder-test destination provides a controlled testing environment
without external dependencies, ideal for platform feature testing,
development workflows, and CI/CD reliability.

refactor: reduce code duplication in rudder_test destination

- Extract common validation and request building logic to utils.ts
- Add processor transformation function alongside existing router function
- Create comprehensive component tests for both processor and router
- Implement shared utilities for message validation, request config building, and test behavior handling
- Maintain different error handling patterns for processor (throws) vs router (returns error objects)
- Add 6 test cases covering success scenarios, error responses, and validation failures

refactor: improve type safety in rudder_test utils

- Replace 'any' types with specific Metadata and RudderTestDestination types
- Import proper types from '../../../types' for better type safety
- Enhance IntelliSense support and compile-time error detection
- Address coderabbitai bot feedback on PR #4352

feat: enhance rudder_test destination with comprehensive dynamic config testing

- Modified rudder_test destination to actually use resolved dynamic config values
- Added endpoint and apiKey resolution from destination config in utils.ts
- Updated transform.ts to pass destination config to utility functions
- Enhanced type definitions to support RudderTestConfig interface

- Added multi-event test cases for both processor and router
- Tests validate multiple events with different dynamic config values resolve correctly
- Added mixed destination ID scenarios (different hasDynamicConfig flags)
- Added compaction tests with multiple events and dynamic config
- All 20 tests now pass and actually validate dynamic config resolution

These tests will surface thread safety issues and shared state problems
in dynamic config processing by testing scenarios where multiple events
have different template variable values that must resolve independently.

docs: update rudder_test destination documentation with dynamic config features

- Added dynamic config resolution capabilities to feature list
- Updated implementation details to reflect both processor and router support
- Added comprehensive test coverage information (20 test cases)
- Included dynamic config examples with template syntax
- Added multi-event testing and thread safety testing use cases
- Updated key files list to include utils.ts and enhanced type definitions
- Corrected architecture description from router-only to dual implementation

* chore: sfmc ai generated docs (#4328)

* chore: sfmc ai generated docs

* chore: sfmc api section in docs

* chore: separate out transformer logic from main doc

* chore: vdm-v2 related faulty docs fix

* Revert "Revert "Merge branch 'develop' into main""

This reverts commit af6e580.

* fix: klaviyo error logging

* chore: optimize usage of deepFreeze in compaction middlewares (#4374)

* chore: use batch processing in transformations (#4363)

* feat: use account information on zoho (#4361)

* chore: new way of creating release

* fix: deep freeze in compaction middleware

- Add test behaviors in rudder_test transform to mutate and replace destination config
- Add router and processor component tests for both property mutation and config
  reference replacement in compacted payload flow
- Assert correct error handling and status codes when mutation is attempted on frozen config
- Ensures immutability of config is enforced and covered in both flows
- Remove unneccessary clonedeep in router transform flow by fixing code

* chore: add safe batch processing to avoid blocking in highly batched destinations

* chore: add batching in mp and source transformations

* fix(marketo): remove auth key from logs

* feat: testing tool (#4391)

* feat: testing tool

* chore: changes

* chore: code structure

* fix: eslint

* chore: review comments

* chore: review comment

* feat: add server request creation flow

* chore: bluecore add internal doc and migrate test (#4353)

* fix: blucore optin event mapping

* fix: review comments

* chore: add subscription event

* chore: add subscription event

* fix: reviews comments

* chore: blucore add internal doc and migrate test

* chore: misc

* chore: misc

* fix: readme

* chore: update docs

* fix(bluecore): address PR #4353 reviewer feedback and API documentation corrections

✅ Complete reviewer feedback resolution:
- Removed all 16 'NEEDS REVIEW' placeholders with concrete information
- Removed AI-generated optimization recommendations section
- Simplified repetitive business logic content by creating detailed businesslogic.md
- Updated documentation structure to follow rs-ai repository standards

🔧 API Documentation Corrections:
- Corrected API type from 'Transactional API' to 'Events API' throughout documentation
- Updated endpoint information to reflect actual implementation: https://api.bluecore.app/api/track/mobile/v1
- Fixed authentication method documentation (namespace token in payload vs Bearer header)
- Updated rate limiting information to reflect Events API (removed incorrect Transactional API limits)
- Updated References section with official Events API documentation link

📚 Documentation Structure Improvements:
- Created comprehensive businesslogic.md with detailed field mappings and transformation flows
- Streamlined main README by removing repetitive sections and adding cross-references
- Consolidated error handling, testing, and performance sections
- Updated RETL documentation for consistency

🔍 Code Analysis Verification:
- Verified endpoint match between code implementation and documentation
- Confirmed authentication method matches actual implementation
- Validated all API references against official Bluecore Events API documentation

Files modified:
- src/cdk/v2/destinations/bluecore/README.md (extensive updates)
- src/cdk/v2/destinations/bluecore/docs/businesslogic.md (created)
- src/cdk/v2/destinations/bluecore/docs/retl.md (updated)

The documentation now accurately reflects the actual Bluecore Events API implementation
and provides reliable information for users integrating with Bluecore through RudderStack.

* chore: docs

* chore: review comments

* fix: review comments

* fix: review comments

* fix: review comments

* chore: improve release check reliability

* fix: ensure the testing tool is cross-platform compatible (#4401)

* fix: make testing tool compatible with cross plateform

* fix: review comments

* fix: review comments

* chore: update klaviyo version to 2024-10-15, remove config restricted changes (#4387)

* chore: criteo audience api version upgrade (#4382)

* chore: criteo audience api version upgrade

* chore: add destination integration doc

* chore: resolving comments

* chore: groupEventsByType function optimization (#4398)

* fix: rt event ordering for hs (#4397)

* fix: router output ordering for tiktok_ads

* fix: test

* fix: test

* fix: test

* fix: rt event ordering for hs

* test: configure batch processing defaults for component tests

* fix: test folder structure for destinations (#4414)

* feat: update workflow to raise pr for dedicated transformer from operator (#4413)

* feat: update workflow to raise pr for dedicated transformer from operator

* Update .github/workflows/prepare-for-prod-dt-deploy.yml

Co-authored-by: Krishna Chaitanya <[email protected]>

* chore: revert rollback changes

---------

Co-authored-by: Sudip Paul <[email protected]>
Co-authored-by: Krishna Chaitanya <[email protected]>

* chore: remove broken workflow to updating dedicated deployment (#4418)

chore: remove broken updating dedicated deployment workflow

Co-authored-by: Sudip Paul <[email protected]>

* chore: update node version to 20.19.2 (#4416)

* chore(mailchimp): add router test with inputs contains different destnations (#4419)

* chore(mailchimp): add router test with inputs contains different destinations

* chore: misc

* chore(release): 1.103.0

* fix: enhance config object in ga4 v2 instead of mutating it (#4436)

* fix: enhance config object in ga4v2 instead of mutation

* chore: update changelog

---------

Co-authored-by: Utsab Chowdhury <[email protected]>
Co-authored-by: Mahesh Kutty <[email protected]>
Co-authored-by: Dilip Kola <[email protected]>
Co-authored-by: Aris Tzoumas <[email protected]>
Co-authored-by: Vinay Teki <[email protected]>
Co-authored-by: Sudip Paul <[email protected]>
Co-authored-by: Dilip Kola <[email protected]>
Co-authored-by: Yashasvi Bajpai <[email protected]>
Co-authored-by: Manish Kumar <[email protected]>
Co-authored-by: Sudip Paul <[email protected]>
Co-authored-by: Krishna Chaitanya <[email protected]>
Co-authored-by: GitHub Actions <[email protected]>
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.

6 participants