Repository navigation
chore: sources v2 spec cleanup - #4192
Conversation
Summary by CodeRabbit
WalkthroughThis pull request removes legacy version (v0/v1) tests and conversion strategies, streamlining the code base for v2 source transformations. The changes include updates to the controller input handling, elimination of outdated conversion logic and version mapping, and simplification of error handling and logging. Additionally, middleware and route logic have been modified to check active versions via a new method, and several tests and test data files have been updated or removed to reflect the new streamlined functionality. Changes
Sequence Diagram(s)sequenceDiagram
participant C as Client
participant RM as RouteActivationMiddleware
participant SC as SourceController
participant IS as IntegrationService
C->>RM: POST /v2/sources/{source}
RM->>RM: isSourceRouteVersionActive(ctx, next)
RM-->>SC: Pass valid request
SC->>IS: sourceTransformRoutine(SourceInputV2, source)
IS-->>SC: Transformation response
SC-->>C: Return response
Suggested reviewers
📜 Recent review detailsConfiguration used: .coderabbit.yaml ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms (10)
🔇 Additional comments (2)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
|
Allure Test reports for this run are available at:
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #4192 +/- ##
===========================================
- Coverage 91.06% 91.05% -0.01%
===========================================
Files 635 627 -8
Lines 33179 33049 -130
Branches 7836 7818 -18
===========================================
- Hits 30213 30092 -121
+ Misses 2718 2710 -8
+ Partials 248 247 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
5b8cc3e to
1bc6754
Compare
50553ad to
0085218
Compare
|
Allure Test reports for this run are available at:
|
0085218 to
8e8a111
Compare
|
Allure Test reports for this run are available at:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/helpers/fetchHandlers.ts (1)
23-28: Consider using class name instead of this in static methodsStatic analysis tools flagged the use of
thisin a static context, which can be confusing.- if (this.sourceHandlerMap.has(source)) { - sourceHandler = this.sourceHandlerMap.get(source); - } else { - sourceHandler = MiscService.getSourceHandler(source); - this.sourceHandlerMap.set(source, sourceHandler); - } + if (FetchHandler.sourceHandlerMap.has(source)) { + sourceHandler = FetchHandler.sourceHandlerMap.get(source); + } else { + sourceHandler = MiscService.getSourceHandler(source); + FetchHandler.sourceHandlerMap.set(source, sourceHandler); + }🧰 Tools
🪛 Biome (1.9.4)
[error] 23-23: Using this in a static context can be confusing.
this refers to the class.
Unsafe fix: Use the class name instead.(lint/complexity/noThisInStatic)
[error] 24-24: Using this in a static context can be confusing.
this refers to the class.
Unsafe fix: Use the class name instead.(lint/complexity/noThisInStatic)
[error] 27-27: Using this in a static context can be confusing.
this refers to the class.
Unsafe fix: Use the class name instead.(lint/complexity/noThisInStatic)
src/features.ts (1)
117-117: Default behavior change forupgradedToSourceTransformV2The logic has been inverted to make v2 the default transformation version unless explicitly disabled. This aligns with the PR objective of focusing on v2 support only. The double negative in the expression
!(process.env.UPGRADED_TO_SOURCE_TRANSFORM_V2 === 'false')is functionally correct but could be slightly improved for readability.- upgradedToSourceTransformV2: !(process.env.UPGRADED_TO_SOURCE_TRANSFORM_V2 === 'false'), + upgradedToSourceTransformV2: process.env.UPGRADED_TO_SOURCE_TRANSFORM_V2 !== 'false',
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (29)
src/controllers/__tests__/source.test.ts(3 hunks)src/controllers/source.ts(1 hunks)src/controllers/util/conversionStrategies/abstractions.ts(0 hunks)src/controllers/util/conversionStrategies/strategyDefault.ts(0 hunks)src/controllers/util/conversionStrategies/strategyV0ToV1.ts(0 hunks)src/controllers/util/conversionStrategies/strategyV1ToV0.ts(0 hunks)src/controllers/util/conversionStrategies/strategyV1ToV2.ts(0 hunks)src/controllers/util/conversionStrategies/strategyV2ToV0.ts(0 hunks)src/controllers/util/conversionStrategies/strategyV2ToV1.ts(0 hunks)src/controllers/util/index.test.ts(0 hunks)src/controllers/util/index.ts(0 hunks)src/controllers/util/versionConversion.ts(0 hunks)src/features.ts(1 hunks)src/helpers/__tests__/fetchHandlers.test.ts(1 hunks)src/helpers/fetchHandlers.ts(1 hunks)src/interfaces/SourceService.ts(1 hunks)src/middlewares/routeActivation.ts(2 hunks)src/routes/source.ts(1 hunks)src/services/__tests__/misc.test.ts(1 hunks)src/services/misc.ts(1 hunks)src/services/source/__tests__/nativeIntegration.test.ts(5 hunks)src/services/source/nativeIntegration.ts(2 hunks)test/apitests/data_scenarios/source/v1/pipedream.json(0 hunks)test/apitests/data_scenarios/source/v2/failure.json(2 hunks)test/apitests/data_scenarios/source/v2/successful.json(1 hunks)test/apitests/service.api.test.ts(1 hunks)test/integrations/component.test.ts(1 hunks)test/integrations/sources/shopify/webhookTestScenarios/IdentifyTests.ts(1 hunks)test/integrations/testTypes.ts(0 hunks)
💤 Files with no reviewable changes (12)
- test/integrations/testTypes.ts
- src/controllers/util/versionConversion.ts
- src/controllers/util/conversionStrategies/strategyDefault.ts
- src/controllers/util/conversionStrategies/strategyV0ToV1.ts
- src/controllers/util/index.test.ts
- src/controllers/util/conversionStrategies/strategyV2ToV1.ts
- src/controllers/util/index.ts
- src/controllers/util/conversionStrategies/abstractions.ts
- test/apitests/data_scenarios/source/v1/pipedream.json
- src/controllers/util/conversionStrategies/strategyV1ToV0.ts
- src/controllers/util/conversionStrategies/strategyV1ToV2.ts
- src/controllers/util/conversionStrategies/strategyV2ToV0.ts
🧰 Additional context used
🧬 Code Definitions (6)
src/routes/source.ts (1)
src/middlewares/routeActivation.ts (1)
RouteActivationMiddleware(22-119)
src/services/__tests__/misc.test.ts (1)
src/services/misc.ts (1)
MiscService(8-75)
src/helpers/__tests__/fetchHandlers.test.ts (2)
src/services/misc.ts (1)
MiscService(8-75)src/helpers/fetchHandlers.ts (1)
FetchHandler(3-42)
src/helpers/fetchHandlers.ts (1)
src/services/misc.ts (1)
MiscService(8-75)
src/controllers/__tests__/source.test.ts (1)
src/services/source/nativeIntegration.ts (1)
NativeIntegrationSourceService(19-74)
test/apitests/service.api.test.ts (11)
test/integrations/sources/shopify/data.ts (1)
data(1497-1510)test/integrations/sources/adjust/data.ts (1)
data(8-184)src/v0/util/index.test.js (1)
data(977-984)test/integrations/destinations/customerio_audience/router/data.ts (1)
data(196-377)src/sources/webhook/transform.js (3)
response(15-20)response(37-37)request(13-13)src/sources/extole/transform.js (1)
response(35-35)src/sources/gainsightpx/transform.js (1)
response(90-90)src/sources/monday/transform.js (1)
response(70-72)src/sources/olark/transform.js (1)
response(54-54)src/sources/satismeter/transform.js (1)
response(24-24)src/sources/slack/transform.js (2)
response(79-79)response(109-111)
🪛 Biome (1.9.4)
src/helpers/fetchHandlers.ts
[error] 23-23: Using this in a static context can be confusing.
this refers to the class.
Unsafe fix: Use the class name instead.
(lint/complexity/noThisInStatic)
[error] 24-24: Using this in a static context can be confusing.
this refers to the class.
Unsafe fix: Use the class name instead.
(lint/complexity/noThisInStatic)
⏰ Context from checks skipped due to timeout of 90000ms (8)
- GitHub Check: ingestion-service-test
- GitHub Check: Check PR Title
- 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: 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: Code Coverage
- GitHub Check: test_and_publish
🔇 Additional comments (36)
test/apitests/data_scenarios/source/v2/successful.json (1)
4-5: Updated test case structure aligns with v2 specificationThe change from using an
eventobject to arequest.bodystring follows the updated v2 specification. This ensures consistent data structure for source transformations.test/apitests/data_scenarios/source/v2/failure.json (2)
4-5: Structure updated to match v2 specificationThe test case now correctly uses the
request.bodystructure consistent with v2 specification, matching the successful case structure.
18-18: Error message path fixedThe error message has been updated to remove the
undefined/segment from the module path, making it more accurate and cleaner.src/routes/source.ts (1)
9-9: Added version validation middlewareThe
isRouteVersionActivemiddleware ensures that only supported versions can access the endpoint. This aligns with the v2 specification cleanup by preventing access to deprecated v0/v1 versions.src/helpers/fetchHandlers.ts (2)
21-21: Simplified method signature by removing version parameterRemoving the version parameter from
getSourceHandlerstreamlines the API to support only v2, which aligns with the overall goal of cleaning up the source specifications.
26-26: Updated call to MiscService.getSourceHandlerThe call has been updated to match the new signature that no longer requires a version parameter. This ensures consistent handler retrieval across the application.
src/services/misc.ts (1)
16-17: Function simplified to standardize on v2 source handlersThe method has been simplified by removing the version parameter, which aligns with the PR objective to focus solely on version v2. This change helps streamline the codebase by eliminating conditional logic for handling different versions.
src/middlewares/routeActivation.ts (2)
7-7: Added constant to explicitly define supported source versionsThe constant
ACTIVE_SOURCE_ROUTE_VERSIONSclearly defines that only 'v2' is supported, which aligns with the PR objective of cleaning up the sources specification to focus on v2.
47-54: Added middleware to enforce v2 route accessThis new middleware method properly implements version validation by checking if the requested version is in the list of active versions. If not, it appropriately returns a 404 response. This is a good way to explicitly enforce the v2-only policy.
src/interfaces/SourceService.ts (1)
1-1: Updated imports to reflect v2 standardizationThe imports have been updated to use
SourceInputV2instead ofSourceInputConversionResult, which aligns with the PR objective of standardizing on v2.src/helpers/__tests__/fetchHandlers.test.ts (2)
17-17: Version parameter removed from getSourceHandlerThe mock implementation now expects only
sourceparameter instead of(source, version). This aligns with the v2 spec cleanup that removes version-specific source handler logic.
24-26: Updated test assertions for sourceHandlerMapThe assertions now correctly reference
sourcevariable instead of previously usingdest, and they test the source handler map without version parameter. This change is consistent with the simplified source handler retrieval approach.src/controllers/__tests__/source.test.ts (4)
44-44: Test suite now focuses on V2 onlyThe test description has been updated to specifically mention "V2 Source transform tests", confirming that v0 and v1 support has been removed as part of the spec cleanup.
52-54: Removed version parameter from mock implementationThe mock implementation now expects data from
getV2Data()and no longer requires a version parameter. This simplifies the API and matches the updated source transform method signature.
64-66: Updated endpoint to v2 and simplified requestThe test now uses the
/v2/sources/__rudder_test__endpoint and sends data directly fromgetV2Data(), aligning with the v2-only approach.
93-97: Updated error handling in failing testThe mock implementation now throws an error directly instead of returning an error response. This change reflects updated error handling behavior in the v2 source transformation implementation.
src/services/source/__tests__/nativeIntegration.test.ts (6)
23-26: Updated event structure to match v2 formatThe event object structure has been updated to use the v2 format with a nested
request.bodyproperty containing stringified JSON, which aligns with the standardized v2 specification.
37-37: Simplified getSourceHandler mock implementationThe mock implementation no longer expects a version parameter, which is consistent with the v2 spec cleanup that removes version-specific handling.
54-54: Removed version parameter from sourceTransformRoutine callThe call to
sourceTransformRoutinehas been updated to exclude the version parameter, aligning with the simplified method signature that focuses only on v2.
65-68: Updated event structure in failure testSimilar to the success test, the event structure in the failure test has been updated to match the v2 format with a nested
request.bodyproperty.
75-75: Simplified getSourceHandler mock in failure testConsistent with the previous changes, the mock implementation in the failure test no longer expects a version parameter.
92-92: Removed version parameter from sourceTransformRoutine call in failure testSimilar to the success test, the call to
sourceTransformRoutinein the failure test has been updated to exclude the version parameter.test/integrations/component.test.ts (3)
210-212: Simplified test data generationThe
extendedTestDatageneration has been simplified to no longer create multiple test cases based on version flags, as part of the v2 spec cleanup that removes support for multiple versions.
220-220: Simplified test function signatureThe test function now takes a simpler parameter structure, removing what was likely version-related parameters, as the tests now only need to handle v2.
228-228: Added initialization of sourceHandlerMapAdded explicit initialization of
FetchHandler['sourceHandlerMap']to a new Map before running source tests, ensuring clean state for each test run and preventing potential test interference.src/services/__tests__/misc.test.ts (1)
19-19: Removal of version parameter aligns with the codebase standardization.The test has been updated to remove the second argument ('v2') when calling
MiscService.getSourceHandler. This is consistent with the changes insrc/services/misc.tswhere the method signature was simplified to only require the source parameter.test/integrations/sources/shopify/webhookTestScenarios/IdentifyTests.ts (1)
1-258: New test file looks well-structured and comprehensive.This new test file properly covers the Shopify customer update event transformation from the Pixel app. The test scenario is detailed and includes both input and expected output, which is valuable for regression testing.
A few observations:
- The test is specific to v2, aligning with the sources v2 spec cleanup objective
- The test data contains comprehensive customer information, including addresses and consent details
- The expected output includes appropriate structure for Rudder's identify call
src/controllers/source.ts (2)
7-7: Import of SourceInputV2 type is appropriate.Adding the
SourceInputV2import supports the type casting on line 13, which provides better type safety for the request body.
13-14: Simplified parameter handling improves code clarity.The changes here properly implement the v2 spec cleanup by:
- Casting the request body to
SourceInputV2[]for better type safety- Removing the
versionparameter from the destructuring, as it's no longer neededsrc/services/source/nativeIntegration.ts (4)
9-9: Import of SourceInputV2 type is appropriate.Adding the
SourceInputV2import supports the parameter type definition on line 35, providing better type safety.
35-36: Parameter type update improves type safety.Changing the parameter type from a conversion result type to
NonNullable<SourceInputV2>[]simplifies the interface and improves type safety, aligning with the v2 spec cleanup goal.
40-40: Handler retrieval simplification is consistent with API changes.Removing the version parameter from
FetchHandler.getSourceHandler()aligns with the changes in theMiscService.getSourceHandler()method, maintaining consistency throughout the codebase.
45-47: Process flow simplification improves code readability.The processing logic has been simplified by:
- Using a more specific return type for
respEvents- Directly calling
sourceHandler.process(sourceEvent)without version-specific handling- Unconditionally returning the result of
handleSuccessEventsSourceThis makes the code more maintainable and focused on v2 processing.
test/apitests/service.api.test.ts (3)
474-475: Good update to v2 path for failure test data!Properly updating the data path from v1 to v2 to reflect the new versioning strategy.
477-477: Endpoint correctly updated to v2!This change aligns with the source transformation v2 specification cleanup by ensuring the test uses the v2 endpoint.
484-490: Good test for backward incompatibility!This test replaces the previous success test for
pipedreamwith a more appropriate test that verifies deprecated version endpoints (v0) return 404 errors. This ensures proper error handling for clients still using older API versions.
|
Allure Test reports for this run are available at:
|
|
Allure Test reports for this run are available at:
|
|
Allure Test reports for this run are available at:
|
|
Allure Test reports for this run are available at:
|
|
Allure Test reports for this run are available at:
|
|
Allure Test reports for this run are available at:
|
|



What are the changes introduced in this PR?
Post the migration to v2 specification, there is no need for any version specific logic as we've consolidated to one final version.
What is the related Linear task?
Resolves INT-2757
Please explain the objectives of your changes below
webhook source improvements project goals
Any changes to existing capabilities/behaviour, mention the reason & what are the changes ?
Yes, deprecation vo, v1 versioning of sources.
Any new dependencies introduced with this change?
No
Any new generic utility introduced or modified. Please explain the changes.
Yes version conversion strategies are completely removed.
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.