Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: version deprecation failure false positive #3104

Merged
merged 11 commits into from
Feb 28, 2024
8 changes: 4 additions & 4 deletions src/v0/destinations/gainsight_px/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ const { getDynamicErrorType } = require('../../../adapters/utils/networkUtils');
const { JSON_MIME_TYPE } = require('../../util/constant');

const handleErrorResponse = (error, customErrMessage, expectedErrStatus, defaultStatus = 400) => {
let destResp;
let errMessage = '';
let errorStatus = defaultStatus;

if (error.response && error.response.data) {
errMessage = error.response.data.externalapierror
? JSON.stringify(error.response.data.externalapierror)
: JSON.stringify(error.response.data);
destResp = error.response?.data?.externalapierror ?? error.response?.data;
errMessage = JSON.stringify(destResp);

errorStatus = error.response.status;

Expand All @@ -26,7 +26,7 @@ const handleErrorResponse = (error, customErrMessage, expectedErrStatus, default
{
[tags.TAG_NAMES.ERROR_TYPE]: getDynamicErrorType(errorStatus),
},
error,
destResp,
);
};

Expand Down
2 changes: 1 addition & 1 deletion src/v0/destinations/sfmc/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const ENDPOINTS = {
GET_TOKEN: `auth.marketingcloudapis.com/v2/token`,
CONTACTS: `rest.marketingcloudapis.com/contacts/v1/contacts`,
INSERT_CONTACTS: `rest.marketingcloudapis.com/hub/v1/dataevents/key:`,
EVENT: "rest.marketingcloudapis.com/interaction/v1/events",
EVENT: 'rest.marketingcloudapis.com/interaction/v1/events',
};

const CONFIG_CATEGORIES = {
Expand Down
29 changes: 29 additions & 0 deletions test/integrations/destinations/gainsight_px/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,33 @@ export const networkCallsData = [
status: 200,
},
},
// Axios Error
{
httpReq: {
url: 'https://api.aptrinsic.com/v1/users/myUId',
headers: { 'X-APTRINSIC-API-KEY': 'sample-api-key', 'Content-Type': 'application/json' },
method: 'GET',
},
httpRes: {
koladilip marked this conversation as resolved.
Show resolved Hide resolved
message: 'Request failed with status code 403',
name: 'AxiosError',
stack:
'AxiosError: Request failed with status code 403\n at settle (/Users/saisankeerth/rudderstack/rudder-transformer/node_modules/axios/lib/core/settle.js:19:12)\n at IncomingMessage.handleStreamEnd (/Users/saisankeerth/rudderstack/rudder-transformer/node_modules/axios/lib/adapters/http.js:589:11)\n at IncomingMessage.emit (node:events:529:35)\n at IncomingMessage.emit (node:domain:489:12)\n at endReadableNT (node:internal/streams/readable:1400:12)\n at processTicksAndRejections (node:internal/process/task_queues:82:21)',
config: {
headers: {
Accept: 'application/json, text/plain, */*',
'Content-Type': 'application/json',
'X-APTRINSIC-API-KEY': 'sample-api-key',
'User-Agent': 'axios/1.6.5',
'Accept-Encoding': 'gzip, compress, deflate, br',
},
method: 'get',
dummy: 'upgrade required', // keyword
url: 'https://api.aptrinsic.com/v1/users/myUId',
},
code: 'FORBIDDEN',
status: 403,
data: '\u003c!doctype html\u003e\u003cmeta charset="utf-8"\u003e\u003cmeta name=viewport content="width=device-width, initial-scale=1"\u003e\u003ctitle\u003e403\u003c/title\u003e403 Forbidden',
},
},
];
153 changes: 153 additions & 0 deletions test/integrations/destinations/gainsight_px/router/data.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,75 @@
const metadata = {
userId: '9a7820d0-0ff2-4451-b655-682cec15cbd2',
jobId: 1,
sourceId: '1s9eG8UCer6YSKsD8ZlQCyLa3pj',
destinationId: 'desId2',
attemptNum: 0,
receivedAt: '2021-06-25T14:29:52.911+05:30',
createdAt: '2021-06-25T08:59:56.329Z',
firstAttemptedAt: '',
transformAt: 'router',
};
const destination2 = {
ID: 'desId2',
Name: 'gainsight-px-dest',
DestinationDefinition: {
ID: 'destDef1',
Name: 'GAINSIGHT_PX',
DisplayName: 'Gainsight PX',
Config: {
destConfig: {
defaultConfig: [
'apiKey',
'productTagKey',
'userAttributeMap',
'accountAttributeMap',
'globalContextMap',
],
},
excludeKeys: [],
includeKeys: [],
saveDestinationResponse: true,
secretKeys: ['apiKey', 'productTagKey'],
supportedSourceTypes: [
'android',
'ios',
'web',
'unity',
'amp',
'cloud',
'reactnative',
'flutter',
],
transformAt: 'router',
transformAtV1: 'router',
},
ResponseRules: {},
},
Config: {
accountAttributeMap: [
{ from: 'LAST_INVOICE_DATE', to: 'last_invoice_date' },
{ from: 'LAST_INVOICE_PLAN', to: 'last_invoice_plan' },
{ from: 'LANGUAGE', to: 'language' },
{ from: 'REGION', to: 'region2' },
{ from: 'LAST_INVOICE_CURRENCY', to: 'last_invoice_currency' },
{ from: 'IBR_PLAN', to: 'ibr_plan' },
{ from: 'WH_COUNTRY', to: 'wh_country' },
{ from: 'inboxready_signup_date', to: 'inboxready_signup_date' },
{ from: 'gpt_setup', to: 'gpt_setup' },
],
oneTrustCookieCategories: [],
apiKey: 'sample-api-key',
eventDelivery: false,
eventDeliveryTS: 1624472902670,
globalContextMap: [{ from: 'kubrickTest', to: 'value' }],
productTagKey: 'AP-SAMPLE-2',
userAttributeMap: [{ from: 'hobbyCustomField', to: 'hobby' }],
},
Enabled: true,
Transformations: [],
IsProcessorEnabled: true,
};

export const data = [
{
name: 'gainsight_px',
Expand Down Expand Up @@ -463,4 +535,85 @@ export const data = [
},
},
},
{
name: 'gainsight_px',
description: 'Test 1: Group call -- AxiosError thrown',
feature: 'router',
module: 'destination',
version: 'v0',
input: {
request: {
body: {
input: [
{
message: {
type: 'group',
sentAt: '2024-02-16T06:00:54.075Z',
traits: {
name: ',sleep(100)',
REGION: 'MEA',
USERID: 'myUId',
groupId: 'myGId',
IBR_PLAN: 'free_ir',
LANGUAGE: 'EN',
gpt_setup: false,
ACCOUNT_ID: 'myGId',
WH_COUNTRY: 'MA',
LAST_INVOICE_DATE: 1706810675000,
LAST_INVOICE_PLAN: 'foundation_trial',
LAST_INVOICE_CURRENCY: 'USD',
inboxready_signup_date: 1680254544705,
},
userId: 'myUId',
channel: 'sources',
context: {
sources: {
job_run_id: 'cn7fjonu4d9b3u706u2g',
task_run_id: 'cn7fjonu4d9b3u706u3g',
},
},
recordId: '111111',
rudderId: 'dummy-rudder-id',
timestamp: '2024-02-16T06:00:52.581Z',
receivedAt: '2024-02-16T06:00:52.582Z',
request_ip: '10.7.150.126',
anonymousId: 'myUId',
integrations: { limitAPIForGroup: true },
originalTimestamp: '2024-02-16T06:00:54.075Z',
},
metadata,
destination: destination2,
},
],
destType: 'gainsight_px',
},
},
},
output: {
response: {
status: 200,
body: {
output: [
{
error:
'{"message":"error while fetching user: \\"<!doctype html><meta charset=\\\\\\"utf-8\\\\\\"><meta name=viewport content=\\\\\\"width=device-width, initial-scale=1\\\\\\"><title>403</title>403 Forbidden\\"","destinationResponse":"<!doctype html><meta charset=\\"utf-8\\"><meta name=viewport content=\\"width=device-width, initial-scale=1\\"><title>403</title>403 Forbidden"}',
statTags: {
destType: 'GAINSIGHT_PX',
destinationId: destination2.ID,
errorCategory: 'network',
errorType: 'aborted',
feature: 'router',
implementation: 'native',
module: 'destination',
},
statusCode: 403,
metadata: [metadata],
batched: false,
destination: destination2,
},
],
},
},
},
},
];
Loading