Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:rudderlabs/rudder-transformer in…
Browse files Browse the repository at this point in the history
…to chore/update-component-test-suite
  • Loading branch information
Sai Sankeerth committed Oct 26, 2023
2 parents 9f2780a + c8baf5b commit ce68813
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ type SourceTransformationResponse = {
type DeliveryResponse = {
status: number;
message: string;
destinationResponse: object;
destinationResponse: any;
statTags: object;
authErrorCategory?: string;
};
Expand Down
22 changes: 12 additions & 10 deletions src/v0/util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1473,13 +1473,22 @@ const getErrorStatusCode = (error, defaultStatusCode = HTTP_STATUS_CODES.INTERNA
/**
* Used for generating error response with stats from native and built errors
*/
function generateErrorObject(error, defTags = {}, shouldEnrichErrorMessage = false) {
let errObject = error;
function generateErrorObject(error, defTags = {}, shouldEnrichErrorMessage = true) {
let errObject = new BaseError(
error.message,
getErrorStatusCode(error),
{
...error.statTags,
...defTags,
},
error.destinationResponse,
error.authErrorCategory,
);
let errorMessage = error.message;
if (shouldEnrichErrorMessage) {
if (error.destinationResponse) {
errorMessage = JSON.stringify({
message: error.message,
message: errorMessage,
destinationResponse: error.destinationResponse,
});
}
Expand All @@ -1488,13 +1497,6 @@ function generateErrorObject(error, defTags = {}, shouldEnrichErrorMessage = fal
if (!(error instanceof BaseError)) {
errObject = new TransformationError(errorMessage, getErrorStatusCode(error));
}

// Add higher level default tags
errObject.statTags = {
...errObject.statTags,
...defTags,
};

return errObject;
}
/**
Expand Down
4 changes: 2 additions & 2 deletions test/__tests__/data/marketo_router_output.json
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@
{
"batched": false,
"statusCode": 400,
"error": "Request Failed for marketo, Lookup field 'userId' not found (Aborted).[Marketo Transformer]: During lead look up using email",
"error": "{\"message\":\"Request Failed for marketo, Lookup field 'userId' not found (Aborted).[Marketo Transformer]: During lead look up using email\",\"destinationResponse\":{\"response\":{\"requestId\":\"142e4#1835b117b76\",\"success\":false,\"errors\":[{\"code\":\"1006\",\"message\":\"Lookup field 'userId' not found\"}]},\"status\":200}}",
"statTags": {
"errorCategory": "network",
"errorType": "aborted"
Expand Down Expand Up @@ -479,7 +479,7 @@
{
"batched": false,
"statusCode": 400,
"error": "Error occurred [Marketo Transformer]: During lead look up using email -> some other problem",
"error": "{\"message\":\"Error occurred [Marketo Transformer]: During lead look up using email -> some other problem\",\"destinationResponse\":{\"response\":{\"requestId\":\"142e4#1835b117b76\",\"success\":false,\"errors\":[{\"code\":\"random_marketo_code\",\"message\":\"some other problem\"}]},\"status\":200}}",
"statTags": {
"errorCategory": "network",
"errorType": "aborted",
Expand Down
120 changes: 102 additions & 18 deletions test/integrations/destinations/autopilot/processor/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,10 @@ export const data = [
type: 'page',
userId: 'user12345',
},
metadata: {
destinationId: 'destId',
workspaceId: 'wspId',
},
},
],
},
Expand All @@ -360,14 +364,21 @@ export const data = [
status: 200,
body: [
{
statusCode: 500,
error: "Cannot read properties of undefined (reading 'destinationId')",
statusCode: 400,
error: 'Bad event. Original error: message type "page" not supported for "autopilot"',
metadata: {
destinationId: 'destId',
workspaceId: 'wspId',
},
statTags: {
errorCategory: 'transformation',
errorCategory: 'dataValidation',
errorType: 'instrumentation',
destType: 'AUTOPILOT',
module: 'destination',
implementation: 'cdkV1',
feature: 'processor',
destinationId: 'destId',
workspaceId: 'wspId',
},
},
],
Expand Down Expand Up @@ -464,6 +475,10 @@ export const data = [
type: 'track',
userId: 'user12345',
},
metadata: {
destinationId: 'destId',
workspaceId: 'wspId',
},
},
],
},
Expand All @@ -473,14 +488,20 @@ export const data = [
status: 200,
body: [
{
statusCode: 500,
error: "Cannot read properties of undefined (reading 'destinationId')",
statusCode: 400,
error: 'Unknown error occurred. Original error: Email is required for track calls',
metadata: {
destinationId: 'destId',
workspaceId: 'wspId',
},
statTags: {
errorCategory: 'transformation',
destType: 'AUTOPILOT',
module: 'destination',
implementation: 'cdkV1',
feature: 'processor',
destinationId: 'destId',
workspaceId: 'wspId',
},
},
],
Expand Down Expand Up @@ -576,6 +597,10 @@ export const data = [
timestamp: '2020-04-17T20:12:44.757+05:30',
userId: 'user12345',
},
metadata: {
destinationId: 'destId',
workspaceId: 'wspId',
},
},
],
},
Expand All @@ -585,13 +610,20 @@ export const data = [
status: 200,
body: [
{
statusCode: 500,
error: "Cannot read properties of undefined (reading 'destinationId')",
statusCode: 400,
error:
'Unknown error occurred. Original error: "type" is a required field and it must be a string',
metadata: {
destinationId: 'destId',
workspaceId: 'wspId',
},
statTags: {
errorCategory: 'transformation',
destType: 'AUTOPILOT',
module: 'destination',
implementation: 'cdkV1',
destinationId: 'destId',
workspaceId: 'wspId',
feature: 'processor',
},
},
Expand Down Expand Up @@ -690,6 +722,10 @@ export const data = [
type: 'group',
userId: 'user12345',
},
metadata: {
destinationId: 'destId',
workspaceId: 'wspId',
},
},
],
},
Expand All @@ -699,13 +735,20 @@ export const data = [
status: 200,
body: [
{
statusCode: 500,
error: "Cannot read properties of undefined (reading 'destinationId')",
statusCode: 400,
error: 'Bad event. Original error: message type "group" not supported for "autopilot"',
metadata: {
destinationId: 'destId',
workspaceId: 'wspId',
},
statTags: {
errorCategory: 'transformation',
errorCategory: 'dataValidation',
errorType: 'instrumentation',
destType: 'AUTOPILOT',
module: 'destination',
implementation: 'cdkV1',
destinationId: 'destId',
workspaceId: 'wspId',
feature: 'processor',
},
},
Expand Down Expand Up @@ -797,6 +840,10 @@ export const data = [
type: 'identify',
userId: 'user12345',
},
metadata: {
destinationId: 'destId',
workspaceId: 'wspId',
},
},
],
},
Expand Down Expand Up @@ -831,6 +878,10 @@ export const data = [
files: {},
userId: 'ac7722c2-ccb6-4ae2-baf6-1effe861f4cd',
},
metadata: {
destinationId: 'destId',
workspaceId: 'wspId',
},
statusCode: 200,
},
],
Expand Down Expand Up @@ -927,6 +978,10 @@ export const data = [
timestamp: '2020-04-17T20:12:44.757+05:30',
userId: 'user12345',
},
metadata: {
destinationId: 'destId',
workspaceId: 'wspId',
},
},
],
},
Expand All @@ -936,13 +991,20 @@ export const data = [
status: 200,
body: [
{
statusCode: 500,
error: "Cannot read properties of undefined (reading 'destinationId')",
statusCode: 400,
error:
'Unknown error occurred. Original error: "type" is a required field and it must be a string',
metadata: {
destinationId: 'destId',
workspaceId: 'wspId',
},
statTags: {
errorCategory: 'transformation',
destType: 'AUTOPILOT',
module: 'destination',
implementation: 'cdkV1',
destinationId: 'destId',
workspaceId: 'wspId',
feature: 'processor',
},
},
Expand Down Expand Up @@ -1034,6 +1096,10 @@ export const data = [
type: 'group',
userId: 'user12345',
},
metadata: {
destinationId: 'destId',
workspaceId: 'wspId',
},
},
],
},
Expand All @@ -1043,13 +1109,20 @@ export const data = [
status: 200,
body: [
{
statusCode: 500,
error: "Cannot read properties of undefined (reading 'destinationId')",
statusCode: 400,
error: 'Bad event. Original error: message type "group" not supported for "autopilot"',
metadata: {
destinationId: 'destId',
workspaceId: 'wspId',
},
statTags: {
errorCategory: 'transformation',
errorCategory: 'dataValidation',
errorType: 'instrumentation',
destType: 'AUTOPILOT',
module: 'destination',
implementation: 'cdkV1',
destinationId: 'destId',
workspaceId: 'wspId',
feature: 'processor',
},
},
Expand Down Expand Up @@ -1141,6 +1214,10 @@ export const data = [
type: 'Tals',
userId: 'user12345',
},
metadata: {
destinationId: 'destId',
workspaceId: 'wspId',
},
},
],
},
Expand All @@ -1150,13 +1227,20 @@ export const data = [
status: 200,
body: [
{
statusCode: 500,
error: "Cannot read properties of undefined (reading 'destinationId')",
statusCode: 400,
error: 'Bad event. Original error: message type "Tals" not supported for "autopilot"',
metadata: {
destinationId: 'destId',
workspaceId: 'wspId',
},
statTags: {
errorCategory: 'transformation',
errorCategory: 'dataValidation',
errorType: 'instrumentation',
destType: 'AUTOPILOT',
module: 'destination',
implementation: 'cdkV1',
destinationId: 'destId',
workspaceId: 'wspId',
feature: 'processor',
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ export const data = [
body: [
{
error:
'Data File Lookup Failed due to {"code":"document_not_found","message":"document_not_found"}: Workflow: procWorkflow, Step: dataFile, ChildStep: undefined, OriginalError: Data File Lookup Failed due to {"code":"document_not_found","message":"document_not_found"}',
'{"message":"Data File Lookup Failed due to {\\"code\\":\\"document_not_found\\",\\"message\\":\\"document_not_found\\"}: Workflow: procWorkflow, Step: dataFile, ChildStep: undefined, OriginalError: Data File Lookup Failed due to {\\"code\\":\\"document_not_found\\",\\"message\\":\\"document_not_found\\"}","destinationResponse":{"code":"document_not_found","message":"document_not_found"}}',
statTags: {
destType: 'OPTIMIZELY_FULLSTACK',
errorCategory: 'platform',
Expand Down
2 changes: 1 addition & 1 deletion test/integrations/destinations/zendesk/processor/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2355,7 +2355,7 @@ export const data = [
body: [
{
error:
"Failed to fetch user with email: testemail2@email due to Couldn't find user: John Wick",
'{"message":"Failed to fetch user with email: testemail2@email due to Couldn\'t find user: John Wick","destinationResponse":{"status":400,"statTags":{"errorCategory":"network","errorType":"aborted","meta":"instrumentation"},"destinationResponse":"","authErrorCategory":""}}',
statTags: {
destType: 'ZENDESK',
errorCategory: 'network',
Expand Down
2 changes: 1 addition & 1 deletion test/integrations/destinations/zendesk/router/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ export const data = [
output: [
{
error:
"Failed to fetch user with email: testemail2@email due to Couldn't find user: John Wick",
'{"message":"Failed to fetch user with email: testemail2@email due to Couldn\'t find user: John Wick","destinationResponse":{"status":400,"statTags":{"errorCategory":"network","errorType":"aborted","meta":"instrumentation"},"destinationResponse":"","authErrorCategory":""}}',
statTags: {
destType: 'ZENDESK',
errorCategory: 'network',
Expand Down

0 comments on commit ce68813

Please sign in to comment.