Repository navigation
feat(mixpanel): add support for partial batch failure handling - #4260
Conversation
Summary by CodeRabbit
Summary by CodeRabbit
WalkthroughThis update introduces comprehensive support for gzip-compressed payloads throughout the proxy request pipeline, including type definitions, utility functions, and network handling logic. New TypeScript interfaces and utility functions are added to facilitate robust response processing, especially for Mixpanel's Import, Engage, and Groups APIs. The Mixpanel destination module now includes a dedicated network handler with endpoint-specific response logic. Extensive unit tests are provided for both utility and network handler modules, ensuring correct processing of various API responses and error scenarios. Configuration constants and improved header handling are also incorporated. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant ProxyAdapter
participant NetworkHandler
participant Utils
participant MixpanelAPI
Client->>ProxyAdapter: Send request (may include GZIP payload)
ProxyAdapter->>Utils: getZippedPayload (if GZIP format)
Utils-->>ProxyAdapter: Compressed payload or error
ProxyAdapter->>NetworkHandler: prepareProxyRequest (with headers)
NetworkHandler->>MixpanelAPI: Send proxy request
MixpanelAPI-->>NetworkHandler: API response
NetworkHandler->>Utils: handleEndpointSpecificResponses (by endpoint)
Utils-->>NetworkHandler: Structured response (success, partial, or error)
NetworkHandler-->>Client: Return standardized response
Suggested reviewers
Suggestions for Improvements:
✨ Finishing Touches
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. 🪧 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
|
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (10)
src/v1/destinations/mp/networkHandler.test.ts (1)
28-362: Comprehensive test cases for responseHandler.The test cases cover a wide range of scenarios including undefined values, successful responses, partial failures, and error conditions for different Mixpanel endpoints. This is excellent test coverage.
Consider adding a descriptive comment for each main test category to improve readability since this is a large array of test cases.
const mainTestCases: TestCase[] = [ + // Tests for undefined or missing values { name: 'undefined destinationRequest', // ... }, + // Tests for Import API scenarios { name: 'successful Import API responses', // ... },src/v1/destinations/mp/networkHandler.ts (1)
70-87: Good implementation of prepareProxyRequest with proper header handling.The prepareProxyRequest function correctly extracts payload data, sets appropriate headers (including special handling for GZIP), and removes undefined values from the result object.
Consider adding defensive checks for undefined request or body to improve robustness.
const prepareProxyRequest = async (request: any): Promise<PrepareProxyResponse> => { + if (!request || !request.body) { + logger.debug('Request or body is undefined'); + return { endpoint: '', data: undefined, method: 'GET', headers: { 'User-Agent': 'RudderLabs' } }; + } const { body, method, params, endpoint, headers, destinationConfig: config } = request; // rest of the function...src/types/delivery.ts (1)
1-17: Type definition for ProxyMetdata is well-structured.The ProxyMetdata type definition is comprehensive, capturing all necessary metadata for proxy requests. However, there's a typo in the type name.
-export type ProxyMetdata = { +export type ProxyMetadata = { jobId: number; attemptNum: number; // ...Note that you'd need to update all references to this type across the codebase if you make this change.
src/v1/destinations/mp/utils.mock.ts (2)
52-71: Unify the “per‑event” response typeHere the helper returns
EventResponse[], while production returnsDeliveryJobState[]. Diverging types increase the cognitive load and open up room for subtle bugs (e.g., accidentally asserting on the wrong field).
Consider standardising on a single exported interface, e.g.:-export interface EventResponse { … } +export type EventResponse = DeliveryJobState; // re‑export aliasOr move the type to a shared
types.ts.
97-120: Propagate response body to the error object
handleNonSuccessResponsethrowsTransformerProxyErrorwith only thedestinationResponseobject. Down‑stream debuggers often need the raw body for RCA. Add abody: destinationResponse.response(or similar) field so Sentry / Datadog can surface the exact Mixpanel payload that failed.src/v1/destinations/mp/utils.ts (5)
52-61: Add generics to improve type‑safety
rudderJobMetadata: any[]leaksanyinto every consumer, defeating the purpose of strong typing.
You can preserve flexibility while remaining typed by introducing a generic:-export const createResponsesForAllEvents = ( - rudderJobMetadata: any[], +export const createResponsesForAllEvents = <T extends unknown>( + rudderJobMetadata: T[], statusCode: number, errorMessage: string, -): DeliveryJobState[] => - rudderJobMetadata.map((metadata) => ({ - statusCode, - metadata, - error: errorMessage, - })); +): DeliveryJobState<T>[] => + rudderJobMetadata.map((metadata) => ({ + statusCode, + metadata, + error: errorMessage, + }));…and update
DeliveryJobStateto be generic (DeliveryJobState<T>). This prevents accidental misuse without compromising flexibility.
216-223: Potential mismatch betweenisAbortableand HTTP status
isAbortable ? 400 : 200is sensible, buterroris set to'success'even for 200. Consider leavingerrorundefined ornullon success to avoid confusion when serialising the multi‑status response.
266-280: Endpoint matching viaincludescan yield false positives
endpoint.includes('/import')will also match/some/importance/test.
If the router ever adds similarly‑named paths you may mis‑route.
Safer: useendpoint.startsWith('/import')or a regex anchored on/.
282-290: Cache the promisifiedgzipfunction
promisify(gzip)is executed on every call. Minor, but you can hoist it once to module scope:const gzipAsync = promisify(gzip); export const getZippedPayload = async (payload: string): Promise<Buffer | undefined> => { try { return await gzipAsync(payload); } catch (err) { …
293-302: Public default export duplicates named exportsDefault‑exporting an object that re‑lists every named export introduces two maintenance points for every new helper. Consider just re‑exporting named exports:
export { checkIfEventIsAbortableInImport, createResponsesForAllEvents, … };Tree‑shakers will thank you.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between f85e8ae and f641375e679df3ebf0e6fdc64dc4d205e7b933f6.
⛔ Files ignored due to path filters (2)
test/integrations/destinations/mp/dataDelivery/data.tsis excluded by!**/test/**test/integrations/destinations/mp/dataDelivery/proxyV1.tsis excluded by!**/test/**
📒 Files selected for processing (11)
src/services/destination/nativeIntegration.ts(1 hunks)src/types/delivery.ts(1 hunks)src/types/destinationTransformation.ts(0 hunks)src/types/index.ts(1 hunks)src/v0/destinations/mp/config.js(2 hunks)src/v1/destinations/mp/networkHandler.test.ts(1 hunks)src/v1/destinations/mp/networkHandler.ts(1 hunks)src/v1/destinations/mp/types.ts(1 hunks)src/v1/destinations/mp/utils.mock.ts(1 hunks)src/v1/destinations/mp/utils.test.ts(1 hunks)src/v1/destinations/mp/utils.ts(1 hunks)
💤 Files with no reviewable changes (1)
- src/types/destinationTransformation.ts
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.js`: Focus on ESLint errors (max 3) and warnings (max 5).
**/*.js: Focus on ESLint errors (max 3) and warnings (max 5).
src/v0/destinations/mp/config.js
🧬 Code Graph Analysis (2)
src/v1/destinations/mp/networkHandler.ts (7)
src/types/delivery.ts (2)
ResponseParams(117-127)ResponseObject(132-138)src/v0/destinations/mp/config.js (1)
DESTINATION(70-70)src/v1/destinations/mp/utils.ts (4)
handleEndpointSpecificResponses(266-280)handleNonSuccessResponse(87-110)createSuccessResponse(71-79)getZippedPayload(282-291)src/v1/destinations/mp/types.ts (1)
PrepareProxyResponse(39-46)src/adapters/network.js (1)
httpSend(200-203)src/v0/util/index.js (1)
removeUndefinedValues(51-51)src/adapters/utils/networkUtils.js (1)
processAxiosResponse(134-167)
src/types/delivery.ts (1)
src/types/rudderEvents.ts (1)
Metadata(89-89)
⏰ Context from checks skipped due to timeout of 90000ms (10)
- 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 ARM64
- GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Code Coverage
- GitHub Check: UT Tests
- GitHub Check: ingestion-service-test
- GitHub Check: test_and_publish
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Analyze (go)
🔇 Additional comments (37)
src/v0/destinations/mp/config.js (2)
70-70: Good addition of the DESTINATION constant.This constant provides a consistent identifier for the Mixpanel destination, which will help standardize references across both v0 and v1 implementations.
92-92: Properly exported the new constant.The DESTINATION constant is correctly added to the module exports, making it available for import by other modules.
src/types/index.ts (1)
8-8: Correctly added export for delivery types.The delivery types export has been properly added to the index file, making these types easily accessible throughout the application.
src/services/destination/nativeIntegration.ts (2)
226-240: Good implementation for ensuring defined responses.This addition ensures that v1 responses always have a defined response array, which improves reliability and consistency in handling batch failures. The approach of mapping through metadata to create job states with appropriate status codes is clean and maintainable.
242-242: Appropriate type casting in return statement.The explicit cast to
DeliveryV0Response | DeliveryV1Responseensures type safety and maintains compatibility with calling code.src/v1/destinations/mp/types.ts (5)
1-11: Well-structured Event interface with proper documentation.The Event interface is clearly defined with appropriate flexibility through the use of index signatures and optional properties. The documentation comments also help explain the purpose of the interface.
12-21: Comprehensive FailedRecord interface for error handling.The FailedRecord interface properly captures the necessary fields for representing failed records, including the required $insert_id, field name, and error message. The index signature allows for additional properties as needed.
22-30: Clear EventResponse interface for standardized responses.The EventResponse interface establishes a consistent structure for event processing responses, including status code, metadata, and error information, which will help with standardizing error handling throughout the application.
31-38: Useful MockProxyMetadata interface for testing.Including a dedicated testing interface is good practice. This will simplify the creation of test fixtures and improve test readability.
39-47: Comprehensive PrepareProxyResponse interface for proxy handling.This interface thoroughly defines the structure for proxy responses, including all necessary HTTP components (endpoint, data, params, headers, method, config). The flexible data type definition accommodates different response formats.
src/v1/destinations/mp/networkHandler.test.ts (7)
2-4: Properly import the error types and response parameters.The import statements are correctly organized, pulling in necessary components from the correct locations. Good job separating the imports based on functionality.
6-11: Test structure follows best practices.The test suite is well-organized with a clear hierarchy using describe blocks. Creating a handler instance in the top-level scope is good for reusability across test cases.
13-26: Well-structured interface for test cases.The
TestCaseinterface provides a clear contract for your test data, making the tests more maintainable and type-safe. Good job defining expected outcomes in the interface.
364-406: Effective use of parameterized testing.Using
test.eachis an excellent approach for running multiple test cases with the same validation logic. The conditional logic for error cases versus success cases is clear and concise.
409-653: Endpoint-specific test cases provide good specialized coverage.The test cases for endpoint-specific handlers are thorough and cover important edge cases like malformed JSON and response handling for different API endpoints. The validation logic checks all relevant parts of the response.
655-765: Comprehensive tests for prepareProxyRequest.The test cases for
prepareProxyRequestcover all payload formats and edge cases like undefined values. Creating a separate handler instance in this describe block is good for test isolation.
767-823: Separate tests for GZIP handling are thorough.Testing GZIP payload handling separately is a good approach since it requires async processing. Both valid and invalid payload scenarios are covered, which is important for error handling.
src/v1/destinations/mp/networkHandler.ts (5)
1-15: Imports are well-organized and functionally grouped.The imports are logically organized, pulling in necessary utilities, loggers, network handlers and type definitions. The explicit imports from './utils' make dependencies clear.
16-46: Well-documented responseHandler function with proper error handling.The responseHandler function is well-documented with JSDoc comments explaining its purpose and parameters. The implementation correctly normalizes metadata, handles endpoint-specific responses, and provides appropriate error handling.
48-68: Clean implementation of payload format extraction.The
extractPayloadForFormatfunction uses a clean approach with an extractors object to map format types to handler functions. The error handling and logging for unknown formats is appropriate.
89-105: Streamlined proxyRequest function.The proxyRequest function has a clean implementation with good separation of concerns. It uses the prepareProxyRequest function to prepare the request options and then uses httpSend to make the request.
107-115: Clear network handler class implementation.The networkHandler class exposes the necessary methods for external use in a clean way. This pattern makes it easy to use these functions in different contexts.
src/v1/destinations/mp/utils.test.ts (9)
1-13: Proper imports for utility functions under test.The import statements are comprehensive, pulling in all utility functions being tested along with required dependencies. This ensures each test has access to the necessary utilities.
14-18: Helpful utility for test failures.Creating a dedicated
failfunction for testing improves readability and provides consistent error messaging. This is good testing practice.
19-49: Good test coverage for createResponsesForAllEvents.The tests for
createResponsesForAllEventscover the main use cases including multiple events and empty metadata. Using parameterized tests makes the code more maintainable.
51-87: Thorough tests for createSuccessResponse.The tests for
createSuccessResponsevalidate both normal operation and edge cases like empty metadata. The expected results are well-defined.
89-271: Comprehensive testing of handleStandardApiResponse.The test cases for
handleStandardApiResponseare thorough, covering non-success status codes, API errors with different event counts, success responses, and different API names. All important scenarios are addressed.
273-329: Good coverage for checkIfEventIsAbortableInImport.The tests for
checkIfEventIsAbortableInImportcover important edge cases like null inputs, missing insert IDs, and matching/non-matching IDs. This ensures robust handling of potential failure conditions.
331-363: Clear tests for handleApiErrorResponse.The tests for
handleApiErrorResponsecover both success cases (no error) and error cases. The expected results are well-defined.
365-428: Good error handling tests for handleNonSuccessResponse.The tests for
handleNonSuccessResponseverify that the function throws the expected error type and that the error contains the expected properties. The try-catch block with explicit validation is a good approach.
430-513: Comprehensive endpoint handling tests.The tests for
handleEndpointSpecificResponsesverify correct routing logic for different Mixpanel endpoints. All important API endpoints are covered, and the unknown endpoint case is handled appropriately.src/types/delivery.ts (5)
19-39: Clear structure for ProxyV0Request type.The ProxyV0Request type is well-defined with all necessary properties for version 0 proxy requests. The types for headers, params, body, and files are appropriately flexible.
41-48: Good use of TypeScript features for ProxyV1Request.Using
Omitto derive ProxyV1Request from ProxyV0Request is a clean approach. The only difference is that metadata is an array in V1, which is clearly expressed.
50-86: Well-structured error reporting types.The error reporting types (ErrorDetailer, ErrorDetailerOptions, MetaTransferObjectForProxy, MetaTransferObject) provide a comprehensive structure for error handling and metadata transfer. The separation of options is a good design choice.
88-112: Clear delivery response type definitions.The DeliveryV0Response and DeliveryV1Response types are well-defined with all necessary properties. The DeliveryJobState type provides a clear structure for tracking job state.
114-138: Good interface definitions for network handlers.The ResponseParams and ResponseObject interfaces provide clear contracts for network handler functions. The use of Partial for extending from delivery responses is a good design choice, and including flexible additional properties via index signature is appropriate.
src/v1/destinations/mp/utils.mock.ts (1)
195-215:/importbranch always returns 200 even for simulated failuresFor the import endpoint the mock short‑circuits to a full success response, whereas the real handler in
utils.tsemits 207 + per‑event statuses. This mismatch may mask partial‑failure paths in tests.
Recommend delegating tohandleImportApiResponsefrom prod utilities or replicating the 207 behaviour here.
|
Allure Test reports for this run are available at:
|
1 similar comment
|
Allure Test reports for this run are available at:
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #4260 +/- ##
===========================================
+ Coverage 91.21% 91.29% +0.07%
===========================================
Files 632 636 +4
Lines 33053 33376 +323
Branches 7827 7892 +65
===========================================
+ Hits 30150 30471 +321
- Misses 2658 2660 +2
Partials 245 245 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (4)
src/v1/destinations/mp/utils.ts (2)
48-60: Consider supporting multiple failure reasons per event
checkIfEventIsAbortableInImportreturns only the first match between$insert_idandfailed_records.
Mixpanel can return multiple failure objects for the sameinsert_id(e.g., several invalid fields). Currently those extra messages are lost.If retaining all messages is valuable, aggregate them:
-const failedRecord = failedRecords.find((record) => record.$insert_id === insertId); -if (!failedRecord) { +const failedMsgs = failedRecords + .filter((r) => r.$insert_id === insertId) + .map((r) => `Field: ${r.field}, Message: ${r.message}`); + +if (!failedMsgs.length) { return { isAbortable: false, errorMsg: '' }; } return { isAbortable: true, - errorMsg: `Field: ${failedRecord.field}, Message: ${failedRecord.message}`, + errorMsg: failedMsgs.join(' | '), };This enhances debuggability without changing the public shape of the response.
293-299: Misleading log message & missing async hint
getZippedPayloadcompresses JSON but the error message says “Failed to parse GZIP payload”. Replace parse with compress to avoid confusion:- logger.error(`Failed to parse GZIP payload: ${err}`); + logger.error(`Failed to gzip payload: ${err}`);Also, the function is synchronous but callers treat it as
await getZippedPayload(...)in tests. Consider:
- Removing the
async/awaitin tests, OR- Returning a
Promise<Buffer | undefined>here to clarify intent.Aligning both sides improves type fidelity.
src/v1/destinations/mp/networkHandler.test.ts (2)
6-12: Instantiate a fresh handler per test to avoid hidden state
networkHandlermay cache configuration or mutate internal fields (e.g., header defaults). Sharing a single instance across 100+ test cases risks order‑dependent failures that are hard to diagnose.-const handler = new networkHandler(); +let handler: networkHandler; -beforeEach(() => { - jest.clearAllMocks(); -}); +beforeEach(() => { + jest.clearAllMocks(); + handler = new networkHandler(); +});Even if the current implementation is stateless, this pattern guards future refactors.
620-623: Remove unnecessary async/await –getZippedPayloadis synchronous
getZippedPayloadreturnsBuffer | undefined, not a promise. The surroundingasync/awaitnoise slows the test runner and misleads readers.-beforeAll(async () => { - gzippedData = await getZippedPayload('{"key":"value"}'); -}); +beforeAll(() => { + gzippedData = getZippedPayload('{"key":"value"}'); +});Apply the same simplification wherever the helper is called.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 6d64007b39b1720e4c79f52116a54bf6c5df3077 and d0be4b18cc26f09bafe1c38296e6703a580973d7.
⛔ Files ignored due to path filters (1)
test/integrations/destinations/mp/dataDelivery/proxyV1.tsis excluded by!**/test/**
📒 Files selected for processing (3)
src/types/destinationTransformation.ts(2 hunks)src/v1/destinations/mp/networkHandler.test.ts(1 hunks)src/v1/destinations/mp/utils.ts(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/types/destinationTransformation.ts
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/v1/destinations/mp/networkHandler.test.ts (3)
src/v1/destinations/mp/networkHandler.ts (1)
networkHandler(114-114)src/types/destinationTransformation.ts (1)
ResponseParams(242-252)src/v1/destinations/mp/utils.ts (1)
getZippedPayload(293-300)
⏰ Context from checks skipped due to timeout of 90000ms (10)
- 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: Build User Transformer Docker Image - PR / Build Transformer Docker Image ARM64
- GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Code Coverage
- GitHub Check: test_and_publish
- GitHub Check: ingestion-service-test
- GitHub Check: UT Tests
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Analyze (go)
🔇 Additional comments (2)
src/v1/destinations/mp/utils.ts (1)
139-164: Using HTTP 200 for logical failure may confuse callers
handleStandardApiResponsemaps a Mixpanel–level error (e.g., Engage/Groups rejecting properties) into an overall HTTP200response, embedding event‑level400s. While this mirrors the existing v0 contract, it can trip up upstream code that interprets the top‑level status alone.If backward compatibility allows, consider returning 207 Multi‑Status at the top level for partial failures, matching what
handleImportApiResponsedoes. At minimum, document this behaviour in JSDoc so integrators don’t assume unconditional success whenstatus === 200.src/v1/destinations/mp/networkHandler.test.ts (1)
757-784: Clarify expectations when GZIP payload is invalidThe test labelled “GZIP invalid payload” expects
data: undefined, yet still treats the overall operation as a success (expect(result).toEqual(expected)). In production an invalid payload would likely translate into a 4xx/5xx transformer error or at least a log line.Consider adding a companion test that verifies
handler.prepareProxyemits a warning or throws whendataisundefined, so failures are surfaced early.
|
Allure Test reports for this run are available at:
|
3 similar comments
|
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:
|
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (4)
src/adapters/network.js (2)
3-3: Consider broader Node‑version compatibility for core‑module importsUsing the
node:prefix ('node:zlib') is perfectly valid, but it requires Node v14.14+.
If the transformer is ever executed with an older runtime (e.g., LTS 12.x still used in some serverless environments) this will throw “Cannot find module ‘node:zlib’”.
A defensive option is to fall back when the prefixed import fails.
335-342: Message wording + early‑type‑guardThe helper compresses the payload but the log message says “parse”. This can be misleading when triaging failures.
Additionally, failing on a non‑string payload is expected behaviour, so a quick type‑check avoids an unhandled exception plus a needless stack‑trace in logs.-const getZippedPayload = (payload) => { - try { - return gzipSync(payload); +const getZippedPayload = (payload) => { + if (typeof payload !== 'string') { + logger.debug('getZippedPayload: expected string, received %s', typeof payload); + return undefined; + } + try { + return gzipSync(payload); } catch (err) { - logger.error(`Failed to parse GZIP payload: ${err}`); + logger.error(`Failed to gzip payload: ${err}`); return undefined; } };src/v1/destinations/mp/networkHandler.test.ts (2)
624-626:awaitis unnecessary for a synchronous helper
getZippedPayloadis synchronous – wrapping it inawaitand marking thebeforeAllasasyncadds needless micro‑tasks and could confuse future maintainers.-beforeAll(async () => { - gzippedData = await getZippedPayload('{"key":"value"}'); -}); +beforeAll(() => { + gzippedData = getZippedPayload('{"key":"value"}'); +});This also means the
beforeAllno longer returns a promise, marginally speeding up the test suite.
7-8: Avoid double instantiation ofnetworkHandlerA second
new networkHandler()is created in theprepareProxyRequestsuite even though an instance already exists at the top of the file. Re‑using the first one keeps the tests a bit lighter and avoids potential divergence if stateful logic is added in the future.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between b6bdfc64476ad56d94a1eb1145e72e1d02e06d2e and d8e51894032754a55e151be0138fbf6354a8941c.
📒 Files selected for processing (6)
src/adapters/network.js(3 hunks)src/types/destinationTransformation.ts(2 hunks)src/v1/destinations/mp/networkHandler.test.ts(1 hunks)src/v1/destinations/mp/networkHandler.ts(1 hunks)src/v1/destinations/mp/types.ts(1 hunks)src/v1/destinations/mp/utils.ts(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
- src/v1/destinations/mp/networkHandler.ts
- src/v1/destinations/mp/types.ts
- src/types/destinationTransformation.ts
- src/v1/destinations/mp/utils.ts
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.js`: Focus on ESLint errors (max 3) and warnings (max 5).
**/*.js: Focus on ESLint errors (max 3) and warnings (max 5).
src/adapters/network.js
🧬 Code Graph Analysis (1)
src/adapters/network.js (3)
src/v1/destinations/mp/utils.ts (1)
getZippedPayload(300-307)src/v0/util/index.js (1)
logger(30-30)src/logger.js (8)
logger(9-21)logger(33-33)logger(119-119)logger(126-126)logger(133-133)logger(140-140)logger(147-147)logger(156-156)
⏰ 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 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)
|
Allure Test reports for this run are available at:
|
|
@maheshkutty resolve sonar issue |
|
Allure Test reports for this run are available at:
|
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (4)
src/v1/destinations/mp/networkHandler.test.ts (4)
8-10: Consider adding more setup or teardown as neededThe test uses
jest.clearAllMocks()in the beforeEach hook, but there don't appear to be any mocks defined in the test file. If mocks are defined in the imported modules, consider documenting this.
600-603: Guard against null/undefined in additional test case assertionsSimilar to the fix for expectedResponseLength, ensure that other properties like expectedStatus are checked before assertions.
expect(result.status).toBe(expectedStatus); -if (expectedResponseLength != undefined) { +if (expectedStatus !== undefined) { + expect(result.status).toBe(expectedStatus); +} +if (expectedResponseLength !== undefined) { expect(result.response).toHaveLength(expectedResponseLength); }
345-347: Consider using strict inequality for type safetyThe code uses
!=for inequality check, which doesn't distinguish betweennullandundefined. Consider using!==for stricter type checking.-if (expectedResponseLength != undefined) { +if (expectedResponseLength !== undefined) { expect(result.response).toHaveLength(expectedResponseLength); }
36-37: Consider reducing @ts-ignore usageThere are numerous @ts-ignore comments throughout the test file. While acceptable for test simplification, consider creating proper test utilities or type definitions for frequently used test data to improve type safety and readability.
Also applies to: 53-55, 87-88, 129-130, 161-162, 191-192, 227-228, 257-258, 293-294, 314-315, 400-401, 429-430, 462-463, 487-488, 508-509, 529-530, 550-551, 575-576
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between cf6922b6eefdb156a17c7a38b18787a2267ab94c and 28a8cca28f4ae1d8094404948eb8e4ec23c33124.
📒 Files selected for processing (3)
src/adapters/network.js(3 hunks)src/adapters/network.test.js(3 hunks)src/v1/destinations/mp/networkHandler.test.ts(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/adapters/network.js
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.js`: Focus on ESLint errors (max 3) and warnings (max 5).
**/*.js: Focus on ESLint errors (max 3) and warnings (max 5).
src/adapters/network.test.js
🧬 Code Graph Analysis (2)
src/adapters/network.test.js (1)
src/adapters/network.js (3)
getZippedPayload(335-342)prepareProxyRequest(371-389)prepareProxyRequest(447-447)
src/v1/destinations/mp/networkHandler.test.ts (2)
src/v1/destinations/mp/networkHandler.ts (1)
networkHandler(51-51)src/types/destinationTransformation.ts (1)
ResponseHandlerParams(242-252)
⏰ Context from checks skipped due to timeout of 90000ms (9)
- 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
- GitHub Check: UT Tests
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Analyze (go)
🔇 Additional comments (5)
src/adapters/network.test.js (4)
3-3: Good addition of error mock method.Adding the error mock to the mockLoggerInstance is appropriate for testing error handling in the new GZIP payload tests.
18-18: Import necessary for GZIP payload tests.This import allows the tests to directly check the GZIP compression functionality in isolation.
893-920: Well-structured test for valid GZIP payload handling.This test correctly verifies that when a valid JSON string is provided in the GZIP field, the function:
- Uses getZippedPayload to compress the data
- Sets the proper Content-Encoding header
- Maintains other headers and properties
The test provides good coverage for the success path of GZIP payload processing.
922-949: Good error case testing for invalid GZIP payload.This test properly verifies the defensive programming approach when an invalid payload (non-string object) is provided. It correctly expects:
- The data field to be undefined (matching the error handling in getZippedPayload)
- The Content-Encoding header to still be set
- Other request properties to remain intact
This ensures robust error handling for malformed inputs.
src/v1/destinations/mp/networkHandler.test.ts (1)
334-347: Good fix for handling undefined expectedResponseLengthThe code correctly checks if
expectedResponseLengthis undefined before using it in the assertion, addressing the previous review comment. This prevents runtime errors when testing error cases.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/v1/destinations/mp/networkHandler.test.ts (2)
405-427: Consider revising this test case configurationThe test case is marked with
expectError: true, which will cause the test to only check if the handler throws aTransformerProxyError. Given the missing batch data scenario, this is likely what you want, but the test name "Import API responses with missing batch data" suggests you might be testing more nuanced behavior.Be explicit about the expected failure mode in the test name to avoid confusion, perhaps "Import API should throw error for missing batch data".
428-453: Similar naming clarification needed for malformed JSON testThis test case is also marked with
expectError: truebut named in a way that suggests it might be testing response handling rather than error throwing.Consider renaming to "Import API should throw error for malformed JSON batch" to more clearly reflect the expected behavior being tested.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 50d585c03f5314510b61cca645d60e68d810f72c and 908366bbb64a3a7fc762638769f65862ed10bc79.
📒 Files selected for processing (1)
src/v1/destinations/mp/networkHandler.test.ts(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/v1/destinations/mp/networkHandler.test.ts (2)
src/v1/destinations/mp/networkHandler.ts (1)
networkHandler(51-51)src/types/destinationTransformation.ts (1)
ResponseHandlerParams(242-252)
⏰ 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 (2)
src/v1/destinations/mp/networkHandler.test.ts (2)
345-347: Well-implemented null checkGood fix for handling undefined
expectedResponseLength. This properly guards against null assertion errors and matches the fix requested in previous reviews.
1-4: Complete test coverage for responseHandlerThe test suite provides comprehensive coverage for the
responseHandlermethod across various scenarios including undefined inputs, successful responses, partial failures, and error conditions for different endpoints.
|
Allure Test reports for this run are available at:
|
There was a problem hiding this comment.
Actionable comments posted: 0
♻️ Duplicate comments (3)
src/v1/destinations/mp/networkHandler.test.ts (3)
406-434: Fix inconsistent test case configurationThis test case for "Import API responses with missing batch data" has contradictory expectations. It's marked with
expectError: truebut also includes expected status properties. When an error is thrown (line 596), the test execution would stop and never evaluate the status assertions.This issue was previously identified in past reviews. Please modify:
{ name: 'Import API responses with missing batch data', responseParams: { // ...response params unchanged... }, - expectError: true, + expectError: false, expectedStatus: 400, // ...other expectations... },Or, if the expectation is truly to throw an error, remove the conflicting status expectations.
436-464: Similar inconsistency in malformed JSON test caseThis test case also has contradictory expectations between
expectError: trueand defined response expectations.Update the expectation flags for consistency:
{ name: 'Import API responses with malformed JSON batch', responseParams: { // ...response params unchanged... }, - expectError: true, + expectError: false, expectedStatus: 400, // ...other expectations... },
5-11: Expand test coverage beyond responseHandlerThe test suite thoroughly tests the
responseHandlermethod but doesn't cover other methods in the networkHandler class such asprepareProxyandproxy.Consider adding test cases for:
handler.prepareProxy- Verify correct proxy request constructionhandler.proxy- Test successful forwarding and error handling#!/bin/bash # Check what other methods are available in networkHandler that might need testing cat src/v1/destinations/mp/networkHandler.ts | grep -E "function|prototype|export" | grep -v "import"
🧹 Nitpick comments (1)
src/v1/destinations/mp/networkHandler.test.ts (1)
593-602: Consider consistent testing patternsThe error handling approach here (using try/catch) differs from the approach in the main test cases (using expect().toThrow). While both are valid, consistent patterns improve maintainability.
Consider using the same pattern as in the main test cases:
if (expectError) { - expect.assertions(2); - try { - handler.responseHandler(responseParams); - } catch (error) { - expect(error).toBeInstanceOf(TransformerProxyError); - const err = error as TransformerProxyError; - expect(err.status).toBe(expectedStatus); - } + expect(() => handler.responseHandler(responseParams)) + .toThrow(TransformerProxyError); + + try { + handler.responseHandler(responseParams); + } catch (error) { + const err = error as TransformerProxyError; + expect(err.status).toBe(expectedStatus); + } } else { // ...
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 908366bbb64a3a7fc762638769f65862ed10bc79 and be706ff74dafa21ab6e415c53af9ade796dd0dc4.
📒 Files selected for processing (1)
src/v1/destinations/mp/networkHandler.test.ts(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Analyze (go)
🔇 Additional comments (3)
src/v1/destinations/mp/networkHandler.test.ts (3)
345-347: Good check for undefined valuesThis null check prevents runtime errors when
expectedResponseLengthis undefined, fixing an issue noted in a previous review.
1-3: LGTM! Clean and focused importsThe imports are clean, focused, and only include what's necessary for testing.
12-26: Well-structured test interfaceThe TestCase interface is comprehensive and provides good type safety for the test parameters.
|
Allure Test reports for this run are available at:
|
be706ff to
e536eb9
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
src/v1/destinations/mp/networkHandler.test.ts (1)
371-622: Test coverage still missing forprepareProxyRequest&proxyRequestPrevious reviews (see past comments) highlighted that only
responseHandleris exercised. The new commit hasn’t added tests for the other public methods exposed bynetworkHandler, so behavioural regressions there would still slip through CI.
Please extend the suite to cover:
prepareProxyRequest– verify URL, headers, body transformation for typical & edge cases.proxyRequest– mock the HTTP client and assert success / error flows.This will bring the test file in line with the class’s public API.
🧹 Nitpick comments (2)
src/v1/destinations/mp/networkHandler.test.ts (2)
20-24: Use the correct Jest asymmetric-matcher type for better type safety
jest.Expectrepresents the interface returned byexpect, not a usable value type.
The current union …error: string | jest.Expect;… will compile but doesn’t convey intent. Prefer the dedicated helper type:
import type { AsymmetricMatcher } from '@jest/types/build/Expect'; error: string | AsymmetricMatcher;(or simply
unknownif you don’t need strict typing).
This prevents accidental misuse and improves IDE hints.
345-360: Simplify the string / matcher branch—toEqualworks for bothBecause asymmetric matchers (
expect.stringContaining,expect.anything, …) implement.asymmetricMatch, they behave correctly withtoEqual(). The explicittypeof === 'string'check and dual branches add noise without functional gain.-if (typeof expectedEvent.error === 'string') { - expect(result.response[index].error).toBe(expectedEvent.error); -} else { - expect(result.response[index].error).toEqual(expectedEvent.error); -} +expect(result.response[index].error).toEqual(expectedEvent.error);This reduces duplication and keeps the assertion logic uniform.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between be706ff74dafa21ab6e415c53af9ade796dd0dc4 and e536eb9.
⛔ Files ignored due to path filters (4)
test/integrations/destinations/mp/dataDelivery/data.tsis excluded by!**/test/**test/integrations/destinations/mp/dataDelivery/proxyV1.tsis excluded by!**/test/**test/integrations/destinations/mp/network.tsis excluded by!**/test/**test/integrations/testUtils.tsis excluded by!**/test/**
📒 Files selected for processing (9)
src/adapters/network.js(3 hunks)src/adapters/network.test.js(3 hunks)src/types/destinationTransformation.ts(2 hunks)src/v0/destinations/mp/config.js(2 hunks)src/v1/destinations/mp/networkHandler.test.ts(1 hunks)src/v1/destinations/mp/networkHandler.ts(1 hunks)src/v1/destinations/mp/types.ts(1 hunks)src/v1/destinations/mp/utils.test.ts(1 hunks)src/v1/destinations/mp/utils.ts(1 hunks)
✅ Files skipped from review due to trivial changes (3)
- src/v1/destinations/mp/networkHandler.ts
- src/types/destinationTransformation.ts
- src/v1/destinations/mp/utils.test.ts
🚧 Files skipped from review as they are similar to previous changes (5)
- src/v0/destinations/mp/config.js
- src/v1/destinations/mp/types.ts
- src/adapters/network.js
- src/adapters/network.test.js
- src/v1/destinations/mp/utils.ts
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/v1/destinations/mp/networkHandler.test.ts (2)
src/v1/destinations/mp/networkHandler.ts (1)
networkHandler(51-51)src/types/destinationTransformation.ts (1)
ResponseHandlerParams(242-252)
⏰ 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 ARM64
- GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Code Coverage
- GitHub Check: UT Tests
- GitHub Check: test_and_publish
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Analyze (go)
🔇 Additional comments (1)
src/v1/destinations/mp/networkHandler.test.ts (1)
1-3: Consider importing the type from its declared module rather than the barrel
ResponseHandlerParamsis defined insrc/types/destinationTransformation.ts, but the test imports it from'../../../types'.
If that barrel file stops re-exporting the interface (or tree-shaking skips it) the test will fail to compile. Importing directly from the defining file makes the dependency explicit:-import { ResponseHandlerParams } from '../../../types'; +import { ResponseHandlerParams } from '../../../types/destinationTransformation';
|
Allure Test reports for this run are available at:
|
|
* chore(docs): update README on how to configure secrets in tests (#4242) * chore: remove conplexity issue and redundant comments (#4250) * chore: remove conplexity issue and redundant comments * chore: address comment * chore(deps): bump rudderlabs/build-scan-push-action from 1.5.2 to 1.5.3 (#4236) chore(deps): bump build scan push action to 1.5.3 Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(pyroscope): use forked pyroscope middleware with latest updates * chore(pyroscope): use forked pyroscope middleware with latest updates * chore(pyroscope): use rudderstack scoped pyroscope nodejs * chore(pyroscope): scope and version change * chore: run ingestion svc test after artefacts build (#4196) * chore: run ingestion svc test after artefacts build * fix: test * fix: test * fix: test * chore: test * chore: test * chore: use go version file * chore: use transformer image * chore: misc * chore: review comment * chore: misc * chore: pass secrets * chore: fix workflow * chore: add docker login * chore: pull image * chore: misc * chore: misc * chore: misc * chore: cleanup * chore: remmove env * chore: remove branch * chore: bump actions/setup-node from 4.0.4 to 4.4.0 (#4262) chore(deps): bump actions/setup-node from 4.0.4 to 4.4.0 Bumps [actions/setup-node](https://github.com/actions/setup-node) from 4.0.4 to 4.4.0. - [Release notes](https://github.com/actions/setup-node/releases) - [Commits](actions/setup-node@v4.0.4...v4.4.0) --- updated-dependencies: - dependency-name: actions/setup-node dependency-version: 4.4.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump codecov/codecov-action from 5.4.0 to 5.4.2 (#4264) Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 5.4.0 to 5.4.2. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](codecov/codecov-action@v5.4.0...v5.4.2) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-version: 5.4.2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore: convert necessary fields to string for pinterest (#4272) * feat: onboarding new destination loops (#3976) (#4235) * feat: identify and track for loops (#3976) * feat: identify and track for loops * feat: test for mailing lists * Update src/cdk/v2/destinations/loops/procWorkflow.yaml Co-authored-by: Yashasvi Bajpai <[email protected]> * fix: added response step; updated tests * fix: better way to get email and userId * feat: some changes * feat: use type --------- Co-authored-by: Yashasvi Bajpai <[email protected]> * fix: minor issues * chore: added test * feat: identify and track for loops (#3976) * feat: identify and track for loops * feat: test for mailing lists * Update src/cdk/v2/destinations/loops/procWorkflow.yaml Co-authored-by: Yashasvi Bajpai <[email protected]> * fix: added response step; updated tests * fix: better way to get email and userId * feat: some changes * feat: use type --------- Co-authored-by: Yashasvi Bajpai <[email protected]> * fix: minor issues * chore: added test * chore: update test to new structure * chore: minor change * chore: minor change --------- Co-authored-by: Dan <[email protected]> Co-authored-by: Yashasvi Bajpai <[email protected]> * feat: onboarding snapchat v3 (#4052) * feat: snapchat v3 * chore: added mappings for v3 * chore: small fix * chore: updated files * feat: onboarding snapchat capi v3 * feat: refactoring and some changes * chore: minor changes * chore: added tests and minor refactoring * fix: minor change * chore: minor changes --------- Co-authored-by: Manish Kumar <[email protected]> Co-authored-by: Manish Kumar <[email protected]> * fix(dynamicConfigParser): fix cloning issue in getdynamicconfig method (#4278) fix(dynamic config): fix cloning issue in getdynamicconfig method Resolves INT-3571 - Fix bug where original event was being modified instead of cloned event - Add comprehensive tests to verify the fix works correctly - Implement table-driven tests for better maintainability * feat(mixpanel): add support for partial batch failure handling (#4260) * feat(mixpanel): add support for partial batch failure handling * chore: misc * fix: handler * fix: handler * fix: review comments * fix: review comments * chore: review comments * chore: review comments * chore: review comments * chore: review comments * chore: review comments * chore: remove unused code * chore: table test case * chore: table test case * fix: test * chore: improve test * chore: upgrade salesforce api version from v50.0 to v63.0 (#4116) Co-authored-by: Manish Kumar <[email protected]> Co-authored-by: Manish Kumar <[email protected]> * chore: return error when gzip compression fails (#4283) chore: return error when gzip compression fails for mp * chore: revert "chore: upgrade salesforce api version from v50.0 to v63.0" (#4285) Revert "chore: upgrade salesforce api version from v50.0 to v63.0 (#4116)" This reverts commit c600f53. * chore: improving code coverage of snapchat conversion (#4284) * chore: improving code coverage of snapchat conversion * chore: minor change * fix: timestamp duration in v2 api * chore(release): 1.98.0 --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Dilip Kola <[email protected]> Co-authored-by: Yashasvi Bajpai <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Vinay Teki <[email protected]> Co-authored-by: Mahesh Kutty <[email protected]> Co-authored-by: Manish Kumar <[email protected]> Co-authored-by: Dan <[email protected]> Co-authored-by: Aanshi Lahoti <[email protected]> Co-authored-by: Manish Kumar <[email protected]> Co-authored-by: GitHub Actions <[email protected]>



What are the changes introduced in this PR?
Write a brief explainer on your code changes.
What is the related Linear task?
Resolves INT-3480
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.