diff --git a/src/services/destination/postTransformation.ts b/src/services/destination/postTransformation.ts index de2f5f1b42..7e9cd52aed 100644 --- a/src/services/destination/postTransformation.ts +++ b/src/services/destination/postTransformation.ts @@ -18,6 +18,7 @@ import { generateErrorObject } from '../../v0/util'; import { ErrorReportingService } from '../errorReporting'; import tags from '../../v0/util/tags'; import stats from '../../util/stats'; +import { FixMe } from '../../util/types'; export class DestinationPostTransformationService { public static handleProcessorTransformSucessEvents( @@ -161,7 +162,7 @@ export class DestinationPostTransformationService { } public static handlevV1DeliveriesFailureEvents( - error: NonNullable, + error: FixMe, metaTo: MetaTransferObject, ): DeliveriesResponse { const errObj = generateErrorObject(error, metaTo.errorDetails, false); @@ -172,7 +173,10 @@ export class DestinationPostTransformationService { } const responses = metadataArray.map((metadata) => { const resp = { - error: errObj.message || '[Delivery] Error occured while processing payload', + error: + JSON.stringify(error.destinationResponse?.response) || + errObj.message || + '[Delivery] Error occured while processing payload', statusCode: errObj.status, metadata, } as DeliveryJobState; diff --git a/test/integrations/destinations/braze/dataDelivery/data.ts b/test/integrations/destinations/braze/dataDelivery/data.ts index cd688a621b..d62361e7f9 100644 --- a/test/integrations/destinations/braze/dataDelivery/data.ts +++ b/test/integrations/destinations/braze/dataDelivery/data.ts @@ -632,7 +632,7 @@ export const data = [ output: { response: [ { - error: 'Request failed for braze with status: 401', + error: '{"code":400,"message":"Bad Req","status":"Fail Case"}', statusCode: 401, metadata: { jobId: 2, @@ -664,4 +664,179 @@ export const data = [ }, }, }, + { + name: 'braze', + description: + 'Test Transformer Proxy V1 input with v0 proxy handler Error returned Multiple metadata Track Event', + feature: 'dataDelivery', + module: 'destination', + version: 'v1', + input: { + request: { + body: { + type: 'REST', + endpoint: 'https://rest.iad-03.braze.com/users/track/testV1', + method: 'POST', + userId: 'gabi_userId_45', + headers: { + Accept: 'application/json', + Authorization: 'Bearer api_key', + 'Content-Type': 'application/json', + }, + body: { + FORM: {}, + JSON: { + partner: 'RudderStack', + attributes: [ + { + email: '123@a.com', + city: 'Disney', + country: 'USA', + firstname: 'Mickey', + external_id: '456345345', + }, + { + email: '123@a.com', + city: 'Disney', + country: 'USA', + firstname: 'Mickey', + external_id: '456345345', + }, + { + email: '123@a.com', + city: 'Disney', + country: 'USA', + firstname: 'Mickey', + external_id: '456345345', + }, + ], + }, + JSON_ARRAY: {}, + XML: {}, + }, + metadata: [ + { + jobId: 2, + attemptNum: 0, + userId: '', + sourceId: '2Vsge2uWYdrLfG7pZb5Y82eo4lr', + destinationId: '2RHh08uOsXqE9KvCDg3hoaeuK2L', + workspaceId: '2Csl0lSTbuM3qyHdaOQB2GcDH8o', + secret: { + access_token: 'secret', + refresh_token: 'refresh', + developer_token: 'developer_Token', + }, + }, + { + jobId: 3, + attemptNum: 0, + userId: '', + sourceId: '2Vsge2uWYdrLfG7pZb5Y82eo4lr', + destinationId: '2RHh08uOsXqE9KvCDg3hoaeuK2L', + workspaceId: '2Csl0lSTbuM3qyHdaOQB2GcDH8o', + secret: { + access_token: 'secret', + refresh_token: 'refresh', + developer_token: 'developer_Token', + }, + }, + { + jobId: 4, + attemptNum: 0, + userId: '', + sourceId: '2Vsge2uWYdrLfG7pZb5Y82eo4lr', + destinationId: '2RHh08uOsXqE9KvCDg3hoaeuK2L', + workspaceId: '2Csl0lSTbuM3qyHdaOQB2GcDH8o', + secret: { + access_token: 'secret', + refresh_token: 'refresh', + developer_token: 'developer_Token', + }, + }, + ], + files: {}, + params: { + destination: 'braze', + }, + }, + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: { + output: { + response: [ + { + error: + '{"message":"Valid data must be provided in the \'attributes\', \'events\', or \'purchases\' fields.","errors":[{"type":"The value provided for the \'email\' field is not a valid email.","input_array":"attributes","index":0},{"type":"The value provided for the \'email\' field is not a valid email.","input_array":"attributes","index":1}]}', + statusCode: 401, + metadata: { + jobId: 2, + attemptNum: 0, + userId: '', + sourceId: '2Vsge2uWYdrLfG7pZb5Y82eo4lr', + destinationId: '2RHh08uOsXqE9KvCDg3hoaeuK2L', + workspaceId: '2Csl0lSTbuM3qyHdaOQB2GcDH8o', + secret: { + access_token: 'secret', + refresh_token: 'refresh', + developer_token: 'developer_Token', + }, + }, + }, + { + error: + '{"message":"Valid data must be provided in the \'attributes\', \'events\', or \'purchases\' fields.","errors":[{"type":"The value provided for the \'email\' field is not a valid email.","input_array":"attributes","index":0},{"type":"The value provided for the \'email\' field is not a valid email.","input_array":"attributes","index":1}]}', + statusCode: 401, + metadata: { + jobId: 3, + attemptNum: 0, + userId: '', + sourceId: '2Vsge2uWYdrLfG7pZb5Y82eo4lr', + destinationId: '2RHh08uOsXqE9KvCDg3hoaeuK2L', + workspaceId: '2Csl0lSTbuM3qyHdaOQB2GcDH8o', + secret: { + access_token: 'secret', + refresh_token: 'refresh', + developer_token: 'developer_Token', + }, + }, + }, + { + error: + '{"message":"Valid data must be provided in the \'attributes\', \'events\', or \'purchases\' fields.","errors":[{"type":"The value provided for the \'email\' field is not a valid email.","input_array":"attributes","index":0},{"type":"The value provided for the \'email\' field is not a valid email.","input_array":"attributes","index":1}]}', + statusCode: 401, + metadata: { + jobId: 4, + attemptNum: 0, + userId: '', + sourceId: '2Vsge2uWYdrLfG7pZb5Y82eo4lr', + destinationId: '2RHh08uOsXqE9KvCDg3hoaeuK2L', + workspaceId: '2Csl0lSTbuM3qyHdaOQB2GcDH8o', + secret: { + access_token: 'secret', + refresh_token: 'refresh', + developer_token: 'developer_Token', + }, + }, + }, + ], + statTags: { + destType: 'BRAZE', + destinationId: '2RHh08uOsXqE9KvCDg3hoaeuK2L', + errorCategory: 'network', + errorType: 'aborted', + feature: 'dataDelivery', + implementation: 'native', + module: 'destination', + workspaceId: '2Csl0lSTbuM3qyHdaOQB2GcDH8o', + }, + }, + }, + }, + }, + }, ]; diff --git a/test/integrations/destinations/braze/network.ts b/test/integrations/destinations/braze/network.ts index 0ef99b806d..3db50ca32c 100644 --- a/test/integrations/destinations/braze/network.ts +++ b/test/integrations/destinations/braze/network.ts @@ -420,5 +420,48 @@ const deleteNwData = [ status: 401, }, }, + { + httpReq: { + url: 'https://rest.iad-03.braze.com/users/track/testV1', + data: { + partner: 'RudderStack', + attributes: [ + { + email: '123@a.com', + city: 'Disney', + country: 'USA', + firstname: 'Mickey', + external_id: '456345345', + }, + { + email: '123@a.com', + city: 'Disney', + country: 'USA', + firstname: 'Mickey', + external_id: '456345345', + }, + { + email: '123@a.com', + city: 'Disney', + country: 'USA', + firstname: 'Mickey', + external_id: '456345345', + }, + ], + }, + params: { destination: 'braze' }, + headers: { + Accept: 'application/json', + Authorization: 'Bearer api_key', + 'Content-Type': 'application/json', + 'User-Agent': 'RudderLabs', + }, + method: 'POST', + }, + httpRes: { + data: '{"message":"Valid data must be provided in the \'attributes\', \'events\', or \'purchases\' fields.","errors":[{"type":"The value provided for the \'email\' field is not a valid email.","input_array":"attributes","index":0},{"type":"The value provided for the \'email\' field is not a valid email.","input_array":"attributes","index":1}]}', + status: 401, + }, + }, ]; export const networkCallsData = [...deleteNwData, ...dataDeliveryMocksData];