Skip to content

feat(mixpanel): add support for partial batch failure handling - #4260

Merged
maheshkutty merged 16 commits into
developfrom
feat.mixpanel_partial_failure
Apr 28, 2025
Merged

maheshkutty merged 16 commits into
developfrom
feat.mixpanel_partial_failure

Conversation

@maheshkutty

Copy link
Copy Markdown
Contributor

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.

@maheshkutty
maheshkutty requested review from a team and sivashanmukh as code owners April 17, 2025 08:02
@maheshkutty
maheshkutty requested review from a team, ItsSudip and utsabc April 17, 2025 08:02
@coderabbitai

coderabbitai Bot commented Apr 17, 2025 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Added support for handling and compressing payloads using GZIP format, including appropriate header management.
    • Introduced new response handling and utility functions for improved processing of Mixpanel API responses.
    • Added new interfaces for event and error record modeling in Mixpanel integrations.
  • Bug Fixes

    • Enhanced handling of invalid or malformed GZIP payloads to prevent processing errors.
  • Tests

    • Added comprehensive test suites for Mixpanel network handlers and utility functions, covering various response scenarios and edge cases.
    • Expanded and refactored tests for proxy request preparation, including GZIP and form payloads.
  • Refactor

    • Improved code structure for payload extraction and proxy request preparation for better maintainability and extensibility.
  • Chores

    • Added new configuration constants for Mixpanel integration.

Summary by CodeRabbit

  • New Features

    • Introduced Mixpanel V1 destination support with robust network handling and response processing.
    • Added gzip-compressed payload support for outgoing requests.
    • Implemented detailed response handling for Mixpanel Import, Engage, and Groups APIs, including partial failure reporting.
    • Added new TypeScript interfaces to support structured response handling and event modeling.
  • Bug Fixes

    • Improved header handling by ensuring headers are properly cloned and set for different payload formats.
    • Enhanced payload extraction logic to handle various formats more reliably.
  • Tests

    • Added comprehensive unit and integration tests for Mixpanel V1 network handler and utility functions.
    • Enhanced test coverage for payload preparation, including gzip and form data scenarios.
  • Refactor

    • Streamlined payload extraction logic for better extensibility and maintainability.

Walkthrough

This 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

File(s) Change Summary
src/types/destinationTransformation.ts Added optional GZIP field to ProxyV0Request body. Introduced ResponseHandlerParams and ResponseProxyObject interfaces for structured response handling.
src/v0/destinations/mp/config.js Added and exported DESTINATION constant for Mixpanel.
src/v1/destinations/mp/networkHandler.ts Introduced networkHandler function with endpoint-specific response handling for Mixpanel proxy integration. Exposes methods for proxying, preparing requests, processing Axios responses, and handling responses.
src/v1/destinations/mp/networkHandler.test.ts Added comprehensive tests for the Mixpanel V1 network handler, covering response handling for various endpoints and error conditions.
src/v1/destinations/mp/types.ts Added Event and FailedRecord interfaces for modeling Mixpanel event payloads and failed records.
src/v1/destinations/mp/utils.ts Added utility functions for parsing payloads, handling gzip, generating responses, and endpoint-specific Mixpanel API response handling. Exports all functions individually and as a default object.
src/v1/destinations/mp/utils.test.ts Added extensive unit tests for Mixpanel utility functions, covering response creation, error handling, abortable event checks, and endpoint-specific logic.
src/adapters/network.js Refactored payload extraction logic to use a map-based extractor with gzip support. Added getZippedPayload function. Updated prepareProxyRequest to clone headers and set Content-Encoding: gzip for GZIP payloads. Exported getZippedPayload.
src/adapters/network.test.js Refactored tests to use table-driven approach for prepareProxyRequest, covering JSON, GZIP (valid/invalid), and empty payloads. Added test for FORM payload. Mock logger updated with error function. Imported getZippedPayload for GZIP tests.

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
Loading

Suggested reviewers

  • krishna2020
  • sivashanmukh
  • vinayteki95

Suggestions for Improvements:

  • Consider consolidating error handling logic across endpoint-specific handlers to reduce code duplication and improve maintainability.
  • Enhance logging around gzip compression failures to ensure issues are promptly detected and diagnosed.
  • Strengthen TypeScript typings for event payloads and failed record structures to catch potential runtime issues earlier.
  • Expand test coverage to include more edge cases, such as malformed or unexpected API responses, to further harden robustness.
✨ Finishing Touches
  • 📝 Generate Docstrings

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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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: 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 type

Here the helper returns EventResponse[], while production returns DeliveryJobState[]. 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 alias

Or move the type to a shared types.ts.


97-120: Propagate response body to the error object

handleNonSuccessResponse throws TransformerProxyError with only the destinationResponse object. Down‑stream debuggers often need the raw body for RCA. Add a body: 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[] leaks any into 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 DeliveryJobState to be generic (DeliveryJobState<T>). This prevents accidental misuse without compromising flexibility.


216-223: Potential mismatch between isAbortable and HTTP status

isAbortable ? 400 : 200 is sensible, but error is set to 'success' even for 200. Consider leaving error undefined or null on success to avoid confusion when serialising the multi‑status response.


266-280: Endpoint matching via includes can 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: use endpoint.startsWith('/import') or a regex anchored on /.


282-290: Cache the promisified gzip function

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 exports

Default‑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.ts is excluded by !**/test/**
  • test/integrations/destinations/mp/dataDelivery/proxyV1.ts is 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 | DeliveryV1Response ensures 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 TestCase interface 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.each is 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 prepareProxyRequest cover 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 extractPayloadForFormat function 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 fail function for testing improves readability and provides consistent error messaging. This is good testing practice.


19-49: Good test coverage for createResponsesForAllEvents.

The tests for createResponsesForAllEvents cover 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 createSuccessResponse validate 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 handleStandardApiResponse are 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 checkIfEventIsAbortableInImport cover 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 handleApiErrorResponse cover 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 handleNonSuccessResponse verify 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 handleEndpointSpecificResponses verify 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 Omit to 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: /import branch always returns 200 even for simulated failures

For the import endpoint the mock short‑circuits to a full success response, whereas the real handler in utils.ts emits 207 + per‑event statuses. This mismatch may mask partial‑failure paths in tests.
Recommend delegating to handleImportApiResponse from prod utilities or replicating the 207 behaviour here.

Comment thread src/v1/destinations/mp/utils.mock.ts Resolved
Comment thread src/v1/destinations/mp/utils.ts Resolved
@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:

@codecov

codecov Bot commented Apr 17, 2025 •

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 98.63946% with 2 lines in your changes missing coverage. Please review.

Project coverage is 91.29%. Comparing base (79cebfc) to head (e536eb9).
Report is 15 commits behind head on develop.

Files with missing lines Patch % Lines
src/v1/destinations/mp/networkHandler.ts 96.00% 1 Missing ⚠️
src/v1/destinations/mp/utils.ts 98.95% 1 Missing ⚠️
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.
📢 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: 4

🧹 Nitpick comments (4)
src/v1/destinations/mp/utils.ts (2)

48-60: Consider supporting multiple failure reasons per event

checkIfEventIsAbortableInImport returns only the first match between $insert_id and failed_records.
Mixpanel can return multiple failure objects for the same insert_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

getZippedPayload compresses 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:

  1. Removing the async/await in tests, OR
  2. 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

networkHandler may 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 – getZippedPayload is synchronous

getZippedPayload returns Buffer | undefined, not a promise. The surrounding async/await noise 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.ts is 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

handleStandardApiResponse maps a Mixpanel–level error (e.g., Engage/Groups rejecting properties) into an overall HTTP 200 response, embedding event‑level 400s. 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 handleImportApiResponse does. At minimum, document this behaviour in JSDoc so integrators don’t assume unconditional success when status === 200.

src/v1/destinations/mp/networkHandler.test.ts (1)

757-784: Clarify expectations when GZIP payload is invalid

The 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.prepareProxy emits a warning or throws when data is undefined, so failures are surfaced early.

Comment thread src/v1/destinations/mp/utils.ts Resolved
Comment thread src/v1/destinations/mp/utils.ts Resolved
Comment thread src/v1/destinations/mp/utils.ts Resolved
@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

3 similar comments
@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:

@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

Comment thread src/types/destinationTransformation.ts Resolved
Comment thread src/types/destinationTransformation.ts Resolved
Comment thread src/v1/destinations/mp/types.ts Resolved

@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: 2

🧹 Nitpick comments (4)
src/adapters/network.js (2)

3-3: Consider broader Node‑version compatibility for core‑module imports

Using 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‑guard

The 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: await is unnecessary for a synchronous helper

getZippedPayload is synchronous – wrapping it in await and marking the beforeAll as async adds needless micro‑tasks and could confuse future maintainers.

-beforeAll(async () => {
-  gzippedData = await getZippedPayload('{"key":"value"}');
-});
+beforeAll(() => {
+  gzippedData = getZippedPayload('{"key":"value"}');
+});

This also means the beforeAll no longer returns a promise, marginally speeding up the test suite.


7-8: Avoid double instantiation of networkHandler

A second new networkHandler() is created in the prepareProxyRequest suite 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)

Comment thread src/adapters/network.js Resolved
Comment thread src/adapters/network.js Resolved
@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

Comment thread src/adapters/network.js Resolved
@krishna2020

Copy link
Copy Markdown
Collaborator

@maheshkutty resolve sonar issue

@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: 4

🧹 Nitpick comments (4)
src/v1/destinations/mp/networkHandler.test.ts (4)

8-10: Consider adding more setup or teardown as needed

The 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 assertions

Similar 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 safety

The code uses != for inequality check, which doesn't distinguish between null and undefined. Consider using !== for stricter type checking.

-if (expectedResponseLength != undefined) {
+if (expectedResponseLength !== undefined) {
   expect(result.response).toHaveLength(expectedResponseLength);
 }

36-37: Consider reducing @ts-ignore usage

There 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:

  1. Uses getZippedPayload to compress the data
  2. Sets the proper Content-Encoding header
  3. 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:

  1. The data field to be undefined (matching the error handling in getZippedPayload)
  2. The Content-Encoding header to still be set
  3. 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 expectedResponseLength

The code correctly checks if expectedResponseLength is undefined before using it in the assertion, addressing the previous review comment. This prevents runtime errors when testing error cases.

@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/v1/destinations/mp/networkHandler.test.ts (2)

405-427: Consider revising this test case configuration

The test case is marked with expectError: true, which will cause the test to only check if the handler throws a TransformerProxyError. 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 test

This test case is also marked with expectError: true but 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 check

Good 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 responseHandler

The test suite provides comprehensive coverage for the responseHandler method across various scenarios including undefined inputs, successful responses, partial failures, and error conditions for different endpoints.

@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

♻️ Duplicate comments (3)
src/v1/destinations/mp/networkHandler.test.ts (3)

406-434: Fix inconsistent test case configuration

This test case for "Import API responses with missing batch data" has contradictory expectations. It's marked with expectError: true but 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 case

This test case also has contradictory expectations between expectError: true and 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 responseHandler

The test suite thoroughly tests the responseHandler method but doesn't cover other methods in the networkHandler class such as prepareProxy and proxy.

Consider adding test cases for:

  • handler.prepareProxy - Verify correct proxy request construction
  • handler.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 patterns

The 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 values

This null check prevents runtime errors when expectedResponseLength is undefined, fixing an issue noted in a previous review.


1-3: LGTM! Clean and focused imports

The imports are clean, focused, and only include what's necessary for testing.


12-26: Well-structured test interface

The TestCase interface is comprehensive and provides good type safety for the test parameters.

@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@maheshkutty
maheshkutty force-pushed the feat.mixpanel_partial_failure branch from be706ff to e536eb9 Compare April 28, 2025 04:27
@maheshkutty
maheshkutty enabled auto-merge (squash) April 28, 2025 04:27

@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

♻️ Duplicate comments (1)
src/v1/destinations/mp/networkHandler.test.ts (1)

371-622: Test coverage still missing for prepareProxyRequest & proxyRequest

Previous reviews (see past comments) highlighted that only responseHandler is exercised. The new commit hasn’t added tests for the other public methods exposed by networkHandler, 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.Expect represents the interface returned by expect, 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 unknown if you don’t need strict typing).
This prevents accidental misuse and improves IDE hints.


345-360: Simplify the string / matcher branch—toEqual works for both

Because asymmetric matchers (expect.stringContaining, expect.anything, …) implement .asymmetricMatch, they behave correctly with toEqual(). The explicit typeof === '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.ts is excluded by !**/test/**
  • test/integrations/destinations/mp/dataDelivery/proxyV1.ts is excluded by !**/test/**
  • test/integrations/destinations/mp/network.ts is excluded by !**/test/**
  • test/integrations/testUtils.ts is 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

ResponseHandlerParams is defined in src/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';

@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@sonarqubecloud

Copy link
Copy Markdown

@maheshkutty
maheshkutty merged commit efe7f21 into develop Apr 28, 2025
@maheshkutty
maheshkutty deleted the feat.mixpanel_partial_failure branch April 28, 2025 04:50
vinayteki95 added a commit that referenced this pull request Apr 29, 2025
* 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]>
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