Skip to content

Commit

Permalink
fix: api contract for v1 proxy (#3049)
Browse files Browse the repository at this point in the history
  • Loading branch information
utsabc authored Feb 2, 2024
2 parents 686f524 + 76e0284 commit 93947db
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
7 changes: 6 additions & 1 deletion src/controllers/delivery.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable prefer-destructuring */
/* eslint-disable sonarjs/no-duplicate-string */
import { Context } from 'koa';
import { isDefinedAndNotNullAndNotEmpty } from '@rudderstack/integrations-lib';
import { MiscService } from '../services/misc';
import {
DeliveryV1Response,
Expand Down Expand Up @@ -84,7 +85,11 @@ export class DeliveryController {
);
}
ctx.body = { output: deliveryResponse };
ControllerUtility.deliveryPostProcess(ctx, deliveryResponse.status);
if (isDefinedAndNotNullAndNotEmpty(deliveryResponse.authErrorCategory)) {
ControllerUtility.deliveryPostProcess(ctx, deliveryResponse.status);
} else {
ControllerUtility.deliveryPostProcess(ctx);
}

logger.debug('Native(Delivery):: Response from transformer::', JSON.stringify(ctx.body));
return ctx;
Expand Down
4 changes: 3 additions & 1 deletion src/services/destination/postTransformation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,11 @@ export class DestinationPostTransformationService {
const resp = {
response: responses,
statTags: errObj.statTags,
authErrorCategory: errObj.authErrorCategory,
message: errObj.message.toString(),
status: errObj.status,
...(errObj.authErrorCategory && {
authErrorCategory: errObj.authErrorCategory,
}),
} as DeliveryV1Response;

ErrorReportingService.reportError(error, metaTo.errorContext, resp);
Expand Down
6 changes: 2 additions & 4 deletions test/integrations/destinations/braze/dataDelivery/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ export const data = [
},
output: {
response: {
status: 401,
status: 200,
body: {
output: {
status: 401,
Expand Down Expand Up @@ -662,7 +662,6 @@ export const data = [
module: 'destination',
workspaceId: '2Csl0lSTbuM3qyHdaOQB2GcDH8o',
},
authErrorCategory: '',
message: 'Request failed for braze with status: 401',
},
},
Expand Down Expand Up @@ -770,7 +769,7 @@ export const data = [
},
output: {
response: {
status: 401,
status: 200,
body: {
output: {
status: 401,
Expand Down Expand Up @@ -840,7 +839,6 @@ export const data = [
module: 'destination',
workspaceId: '2Csl0lSTbuM3qyHdaOQB2GcDH8o',
},
authErrorCategory: '',
message: 'Request failed for braze with status: 401',
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ export const otherScenariosV1 = [
},
output: {
response: {
status: 500,
status: 200,
body: {
output: {
response: [
Expand Down Expand Up @@ -284,7 +284,6 @@ export const otherScenariosV1 = [
destinationId: 'default-destinationId',
workspaceId: 'default-workspaceId',
},
authErrorCategory: '',
message:
'Campaign Manager: Error transformer proxy v1 during CAMPAIGN_MANAGER response transformation',
status: 500,
Expand Down Expand Up @@ -312,7 +311,7 @@ export const otherScenariosV1 = [
},
output: {
response: {
status: 500,
status: 200,
body: {
output: {
response: [
Expand Down Expand Up @@ -343,7 +342,6 @@ export const otherScenariosV1 = [
destinationId: 'default-destinationId',
workspaceId: 'default-workspaceId',
},
authErrorCategory: '',
message:
'Campaign Manager: Error transformer proxy v1 during CAMPAIGN_MANAGER response transformation',
status: 500,
Expand Down Expand Up @@ -371,7 +369,7 @@ export const otherScenariosV1 = [
},
output: {
response: {
status: 500,
status: 200,
body: {
output: {
response: [
Expand Down Expand Up @@ -402,7 +400,6 @@ export const otherScenariosV1 = [
destinationId: 'default-destinationId',
workspaceId: 'default-workspaceId',
},
authErrorCategory: '',
message:
'Campaign Manager: Error transformer proxy v1 during CAMPAIGN_MANAGER response transformation',
status: 500,
Expand Down Expand Up @@ -430,7 +427,7 @@ export const otherScenariosV1 = [
},
output: {
response: {
status: 500,
status: 200,
body: {
output: {
response: [
Expand Down Expand Up @@ -461,7 +458,6 @@ export const otherScenariosV1 = [
destinationId: 'default-destinationId',
workspaceId: 'default-workspaceId',
},
authErrorCategory: '',
message:
'Campaign Manager: Error transformer proxy v1 during CAMPAIGN_MANAGER response transformation',
status: 500,
Expand Down Expand Up @@ -490,7 +486,7 @@ export const otherScenariosV1 = [
},
output: {
response: {
status: 500,
status: 200,
body: {
output: {
response: [
Expand Down Expand Up @@ -521,7 +517,6 @@ export const otherScenariosV1 = [
destinationId: 'default-destinationId',
workspaceId: 'default-workspaceId',
},
authErrorCategory: '',
message:
'Campaign Manager: Error transformer proxy v1 during CAMPAIGN_MANAGER response transformation',
status: 500,
Expand Down

0 comments on commit 93947db

Please sign in to comment.