Skip to content

Commit

Permalink
fix(cdkv1): error handling for cdkv1 destinations (#2227)
Browse files Browse the repository at this point in the history
* fix: error handling for cdkv1 destinations

Signed-off-by: Sai Sankeerth <sanpj2292@github.com>

* fix: modified failure test-case for zapier service integration test

Signed-off-by: Sai Sankeerth <sanpj2292@github.com>

---------

Signed-off-by: Sai Sankeerth <sanpj2292@github.com>
Co-authored-by: Sai Sankeerth <sanpj2292@github.com>
  • Loading branch information
sanpj2292 and Sai Sankeerth committed Jun 1, 2023
1 parent 6732f5e commit c3aedbf
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/cdk/v1/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,5 @@ async function processCdkV1(destType, parsedEvent) {

module.exports = {
processCdkV1,
getErrorInfo,
};
14 changes: 12 additions & 2 deletions src/services/destination/cdkV1Integration.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ConfigFactory, Executor } from 'rudder-transformer-cdk';
import { ConfigFactory, Executor, RudderBaseConfig } from 'rudder-transformer-cdk';
import path from 'path';
import IntegrationDestinationService from '../../interfaces/DestinationService';
import {
Expand All @@ -16,6 +16,7 @@ import {
import { TransformationError } from '../../v0/util/errorTypes';
import DestinationPostTransformationService from './postTransformation';
import tags from '../../v0/util/tags';
import { getErrorInfo } from '../../cdk/v1/handler';

export default class CDKV1DestinationService implements IntegrationDestinationService {
public init() {
Expand Down Expand Up @@ -49,6 +50,15 @@ export default class CDKV1DestinationService implements IntegrationDestinationSe
return metaTO;
}

private async processCDKV1(event: any, tfConfig: RudderBaseConfig): Promise<any> {
try {
const respEvents = await Executor.execute(event, tfConfig);
return respEvents;
} catch (error) {
throw getErrorInfo(error);
}
}

public async doProcessorTransformation(
events: ProcessorTransformationRequest[],
destinationType: string,
Expand All @@ -59,7 +69,7 @@ export default class CDKV1DestinationService implements IntegrationDestinationSe
const respList: ProcessorTransformationResponse[][] = await Promise.all(
events.map(async (event) => {
try {
const transformedPayloads: any = await Executor.execute(event as any, tfConfig);
const transformedPayloads: any = await this.processCDKV1(event as any, tfConfig);
// We are not passing destinationHandler to post processor as we don't have post processing in CDK flows
return DestinationPostTransformationService.handleProcessorTransformSucessEvents(
event,
Expand Down
4 changes: 2 additions & 2 deletions test/__tests__/integration/data_scenarios/cdk_v1/failure.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@
"sourceDefinitionId": "1b6gJdqOPOCadT3cddw8eidV591",
"destinationDefinitionId": ""
},
"statusCode": 500,
"error": "Unsupported \"channel\": \"offline\". It must be one of: web,server,mobile,sources",
"statusCode": 400,
"error": "Unknown error occurred. Original error: Unsupported \"channel\": \"offline\". It must be one of: web,server,mobile,sources",
"statTags": {
"errorCategory": "transformation",
"destType": "ZAPIER",
Expand Down

0 comments on commit c3aedbf

Please sign in to comment.