Skip to content

chore: include transformation name in error stack trace - #4547

Merged
Jayachand merged 3 commits into
developfrom
chore.tr-name-in-stack-trace
Aug 12, 2025
Merged

Jayachand merged 3 commits into
developfrom
chore.tr-name-in-stack-trace

Conversation

@Jayachand

Copy link
Copy Markdown
Collaborator

What are the changes introduced in this PR?

Write a brief explainer on your code changes.

What is the related Linear task?

Resolves DAW-1526

Please explain the objectives of your changes below

Put down any required details on the broader aspect of your changes. If there are any dependent changes, mandatorily mention them here

Any changes to existing capabilities/behaviour, mention the reason & what are the changes ?

N/A

Any new dependencies introduced with this change?

N/A

Any new generic utility introduced or modified. Please explain the changes.

N/A

Any technical or performance related pointers to consider with the change?

N/A

@coderabbitai review


Developer checklist

  • My code follows the style guidelines of this project

  • No breaking changes are being introduced.

  • All related docs linked with the PR?

  • All changes manually tested?

  • Any documentation changes needed with this change?

  • Is the PR limited to 10 file changes?

  • Is the PR limited to one linear task?

  • Are relevant unit and component test-cases added in new readability format?

Reviewer checklist

  • Is the type of change in the PR title appropriate as per the changes?

  • Verified that there are no credentials or confidential data exposed with the changes.

@Jayachand
Jayachand requested review from a team as code owners August 4, 2025 07:59
@Jayachand
Jayachand requested review from ItsSudip and utsabc August 4, 2025 07:59
@coderabbitai

coderabbitai Bot commented Aug 4, 2025 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (2)
  • test/__tests__/data/user_transformation_async_output_with_errors.json is excluded by !**/test/**, !**/*.json
  • test/__tests__/data/user_transformation_service_filter_output.json is excluded by !**/test/**, !**/*.json

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
    • Enhanced transformation handling to display more descriptive filenames for user transformations during processing, improving clarity in module identification.

Walkthrough

The changes introduce a new transformationName parameter to the createIvm and getFactory functions in ivmFactory.js, propagate it through the relevant call chain, and update its usage to dynamically set the filename during module compilation. The call site in customTransformer-v1.js is updated to supply this parameter, defaulting to 'base transformation' if not provided.

Changes

Cohort / File(s) Change Summary
Propagate transformationName parameter
src/util/ivmFactory.js
Added a transformationName parameter to createIvm and getFactory; used it to set the filename in module compilation, replacing the static string. Function signatures updated accordingly.
Update getFactory call site
src/util/customTransformer-v1.js
Modified the call to getFactory to include userTransformation.name or default to 'base transformation' as the new argument. No other logic changed.

Sequence Diagram(s)

sequenceDiagram
    participant CustomTransformer as customTransformer-v1.js
    participant IvmFactory as ivmFactory.js
    participant Isolate as isolate.compileModule

    CustomTransformer->>IvmFactory: getFactory(..., transformationName)
    IvmFactory->>Isolate: compileModule(code, { filename: transformationName })
    Isolate-->>IvmFactory: CompiledModule
    IvmFactory-->>CustomTransformer: FactoryInstance
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Suggested reviewers

  • manish339k
  • sivashanmukh

Suggestions for improvement:

  • Consider documenting the purpose and expected values for the new transformationName parameter in the relevant function docstrings.
  • Ensure that all upstream callers of createIvm and getFactory are updated to provide the new parameter, or supply a default to avoid runtime errors.
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore.tr-name-in-stack-trace

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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

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

CodeRabbit Commands (Invoked using PR/Issue comments)

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

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.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

@codecov

codecov Bot commented Aug 4, 2025 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.79%. Comparing base (7ae313f) to head (4354e4c).
⚠️ Report is 30 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4547      +/-   ##
===========================================
+ Coverage    91.63%   91.79%   +0.16%     
===========================================
  Files          643      642       -1     
  Lines        34020    33886     -134     
  Branches      8048     8023      -25     
===========================================
- Hits         31174    31107      -67     
+ Misses        2588     2527      -61     
+ Partials       258      252       -6     

☔ 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.

@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

🔭 Outside diff range comments (1)
src/util/ivmFactory.js (1)

33-42: Provide default & validation for transformationName

createIvm now depends on transformationName being a non-empty string. Any existing call sites that haven’t been updated (e.g. internal tooling, unit tests, scripts) will hit isolate.compileModule() with undefined, which crashes the isolate before we enter our catch-blocks.

A minimal hardening:

 async function createIvm(
   code,
   libraryVersionIds,
   transformationId,
   workspaceId,
   credentials,
   secrets,
   testMode,
-  transformationName,
+  transformationName = 'base transformation',
 ) {
+  if (typeof transformationName !== 'string' || !transformationName.trim()) {
+    throw new TypeError('transformationName must be a non-empty string');
+  }

This keeps backwards compatibility and guarantees a stable filename in the stack trace.

🧹 Nitpick comments (3)
src/util/ivmFactory.js (2)

417-419: Potential filename pollution in stack traces

isolate.compileModule(..., { filename: transformationName }) will surface the raw string in stack traces. If transformationName contains path separators, new-lines, or unprintable chars the trace becomes noisy and harder to read.
After adding the default/validation above, consider a lightweight sanitiser:

const safeFileName = transformationName.replace(/[^\w\s\-\.]/g, '_');
const customScriptModule = await isolate.compileModule(codeWithWrapper, { filename: safeFileName });

480-501: Long positional parameter list – consider an options object

Both createIvm and getFactory now carry nine positional parameters, which is error-prone and hard to maintain. Moving to an { code, libraryVersionIds, … } options object (or using a typed schema) will make future changes safer.

src/util/customTransformer-v1.js (1)

66-75: Avoid duplicating the default transformation name

'base transformation' is now hard-coded here and in the safeguard we added to ivmFactory. Extracting a shared constant (e.g. const DEFAULT_TRANSFORMATION_NAME = 'base transformation';) keeps the fallback in one place and reduces drift.

-    userTransformation.name || 'base transformation',
+    userTransformation.name || DEFAULT_TRANSFORMATION_NAME,

Declare the constant either in this module or export it from ivmFactory.js.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 65868f6 and ee3142e.

⛔ Files ignored due to path filters (1)
  • test/__tests__/user_transformation_errors.test.js is excluded by !**/test/**
📒 Files selected for processing (2)
  • src/util/customTransformer-v1.js (1 hunks)
  • src/util/ivmFactory.js (4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.js

⚙️ CodeRabbit Configuration File

Focus on ESLint errors (max 3) and warnings (max 5).

Files:

  • src/util/customTransformer-v1.js
  • src/util/ivmFactory.js
🧠 Learnings (1)
📓 Common learnings
Learnt from: vinayteki95
PR: rudderlabs/rudder-transformer#4220
File: src/middlewares/routerTransformCompactedPayloadV1.ts:13-24
Timestamp: 2025-04-02T08:21:38.217Z
Learning: In the Rudder Transformer codebase, use generic Error objects instead of TransformationError when error monitoring with Bugsnag is needed, as TransformationError is configured to not trigger Bugsnag alerts.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (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 (go)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (1)
src/util/ivmFactory.js (1)

480-501: Ensure all getFactory invocations include the new transformationName parameter

Our initial regex didn’t flag any missing arguments, but it can miss multi-line calls. Please manually review every getFactory( call to confirm you’ve passed transformationName as the last argument—otherwise you’ll silently shift parameters (e.g. testMode receiving the name string).

• To locate and inspect each call, run:

rg 'getFactory\s*\(' -g '*.js' -A10 -B1

and verify each invocation has eight arguments.

@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@sonarqubecloud

sonarqubecloud Bot commented Aug 12, 2025 •

Copy link
Copy Markdown

@Jayachand
Jayachand merged commit ffbd7f6 into develop Aug 12, 2025
@Jayachand
Jayachand deleted the chore.tr-name-in-stack-trace branch August 12, 2025 07:48
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.

4 participants