Skip to content

Commit

Permalink
fix: updated error response of v1 proxy (#2906)
Browse files Browse the repository at this point in the history
  • Loading branch information
aashishmalik authored Dec 13, 2023
1 parent aad2480 commit 7825c19
Show file tree
Hide file tree
Showing 3 changed files with 225 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/services/destination/postTransformation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -161,7 +162,7 @@ export class DestinationPostTransformationService {
}

public static handlevV1DeliveriesFailureEvents(
error: NonNullable<unknown>,
error: FixMe,
metaTo: MetaTransferObject,
): DeliveriesResponse {
const errObj = generateErrorObject(error, metaTo.errorDetails, false);
Expand All @@ -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;
Expand Down
177 changes: 176 additions & 1 deletion test/integrations/destinations/braze/dataDelivery/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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: '[email protected]',
city: 'Disney',
country: 'USA',
firstname: 'Mickey',
external_id: '456345345',
},
{
email: '[email protected]',
city: 'Disney',
country: 'USA',
firstname: 'Mickey',
external_id: '456345345',
},
{
email: '[email protected]',
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',
},
},
},
},
},
},
];
43 changes: 43 additions & 0 deletions test/integrations/destinations/braze/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,5 +420,48 @@ const deleteNwData = [
status: 401,
},
},
{
httpReq: {
url: 'https://rest.iad-03.braze.com/users/track/testV1',
data: {
partner: 'RudderStack',
attributes: [
{
email: '[email protected]',
city: 'Disney',
country: 'USA',
firstname: 'Mickey',
external_id: '456345345',
},
{
email: '[email protected]',
city: 'Disney',
country: 'USA',
firstname: 'Mickey',
external_id: '456345345',
},
{
email: '[email protected]',
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];

0 comments on commit 7825c19

Please sign in to comment.