Skip to content

Commit

Permalink
Merge branch 'develop' into gaoc.refactor-proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
mihir-4116 authored Mar 13, 2024
2 parents df55dee + 67fcdd3 commit b404ef4
Show file tree
Hide file tree
Showing 9 changed files with 295 additions and 23 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/dt-test-and-report-code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ jobs:
- name: Upload Coverage Reports to Codecov
uses: codecov/[email protected]
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
directory: ./reports/coverage

Expand Down
10 changes: 5 additions & 5 deletions src/controllers/bulkUpload.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/* eslint-disable global-require, import/no-dynamic-require, @typescript-eslint/no-unused-vars */
import { client as errNotificationClient } from '../util/errorNotifier';
import logger from '../logger';
import {
getJobStatusHandler,
getPollStatusHandler,
getDestFileUploadHandler,
} from '../util/fetchDestinationHandlers';
import { CatchErr, ContextBodySimple } from '../util/types';
// TODO: To be refactored and redisgned

const getDestFileUploadHandler = (version, dest) =>
require(`../${version}/destinations/${dest}/fileUpload`);
const getPollStatusHandler = (version, dest) => require(`../${version}/destinations/${dest}/poll`);
const getJobStatusHandler = (version, dest) =>
require(`../${version}/destinations/${dest}/fetchJobStatus`);
const ERROR_MESSAGE_PROCESSOR_STRING = 'Error occurred while processing payload.';

const getCommonMetadata = (ctx) =>
Expand Down
42 changes: 42 additions & 0 deletions src/util/fetchDestinationHandlers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import * as V0MarketoBulkUploadFileUpload from '../v0/destinations/marketo_bulk_upload/fileUpload';
import * as V0MarketoBulkUploadPollStatus from '../v0/destinations/marketo_bulk_upload/poll';
import * as V0MarketoBulkUploadJobStatus from '../v0/destinations/marketo_bulk_upload/fetchJobStatus';

const fileUploadHandlers = {
v0: {
marketo_bulk_upload: V0MarketoBulkUploadFileUpload,
},
};

const pollStatusHandlers = {
v0: {
marketo_bulk_upload: V0MarketoBulkUploadPollStatus,
},
};

const jobStatusHandlers = {
v0: {
marketo_bulk_upload: V0MarketoBulkUploadJobStatus,
},
};

export const getDestFileUploadHandler = (version, dest) => {
if (fileUploadHandlers[version] && fileUploadHandlers[version][dest]) {
return fileUploadHandlers[version][dest];
}
return undefined;
};

export const getPollStatusHandler = (version, dest) => {
if (pollStatusHandlers[version] && pollStatusHandlers[version][dest]) {
return pollStatusHandlers[version][dest];
}
return undefined;
};

export const getJobStatusHandler = (version, dest) => {
if (jobStatusHandlers[version] && jobStatusHandlers[version][dest]) {
return jobStatusHandlers[version][dest];
}
return undefined;
};
4 changes: 2 additions & 2 deletions src/v1/destinations/campaign_manager/networkHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ const responseHandler = (responseParams) => {
const errorMessage = response.error?.message || 'unknown error format';
for (const metadata of rudderJobMetadata) {
responseWithIndividualEvents.push({
statusCode: 500,
statusCode: status,
metadata,
error: errorMessage,
});
}

throw new TransformerProxyError(
`Campaign Manager: Error transformer proxy v1 during CAMPAIGN_MANAGER response transformation`,
500,
status,
{
[tags.TAG_NAMES.ERROR_TYPE]: getDynamicErrorType(status),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,14 +326,14 @@ export const v1oauthScenarios: ProxyV1TestData[] = [
},
output: {
response: {
status: 500,
status: 401,
body: {
output: {
response: [
{
error:
'{"error":{"code":401,"message":"Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.","errors":[{"message":"Login Required.","domain":"global","reason":"required","location":"Authorization","locationType":"header"}],"status":"UNAUTHENTICATED","details":[{"@type":"type.googleapis.com/google.rpc.ErrorInfo","reason":"CREDENTIALS_MISSING","domain":"googleapis.com","metadata":{"method":"google.ads.xfa.op.v4.DfareportingConversions.Batchinsert","service":"googleapis.com"}}]}}',
statusCode: 500,
statusCode: 401,
metadata: {
jobId: 1,
attemptNum: 1,
Expand Down Expand Up @@ -361,7 +361,7 @@ export const v1oauthScenarios: ProxyV1TestData[] = [
authErrorCategory: 'REFRESH_TOKEN',
message:
'Campaign Manager: Error transformer proxy v1 during CAMPAIGN_MANAGER response transformation',
status: 500,
status: 401,
},
},
},
Expand Down Expand Up @@ -389,14 +389,14 @@ export const v1oauthScenarios: ProxyV1TestData[] = [
},
output: {
response: {
status: 500,
status: 403,
body: {
output: {
response: [
{
error:
'{"error":{"code":403,"message":"Request had insufficient authentication scopes.","errors":[{"message":"Insufficient Permission","domain":"global","reason":"insufficientPermissions"}],"status":"PERMISSION_DENIED","details":[{"@type":"type.googleapis.com/google.rpc.ErrorInfo","reason":"ACCESS_TOKEN_SCOPE_INSUFFICIENT","domain":"googleapis.com","metadata":{"service":"gmail.googleapis.com","method":"caribou.api.proto.MailboxService.GetProfile"}}]}}',
statusCode: 500,
statusCode: 403,
metadata: {
jobId: 1,
attemptNum: 1,
Expand Down Expand Up @@ -424,7 +424,7 @@ export const v1oauthScenarios: ProxyV1TestData[] = [
authErrorCategory: 'AUTH_STATUS_INACTIVE',
message:
'Campaign Manager: Error transformer proxy v1 during CAMPAIGN_MANAGER response transformation',
status: 500,
status: 403,
},
},
},
Expand Down Expand Up @@ -452,14 +452,14 @@ export const v1oauthScenarios: ProxyV1TestData[] = [
},
output: {
response: {
status: 500,
status: 403,
body: {
output: {
response: [
{
error:
'{"error":{"code":403,"message":"invalid_grant","error_description":"Bad accesss"}}',
statusCode: 500,
statusCode: 403,
metadata: {
jobId: 1,
attemptNum: 1,
Expand Down Expand Up @@ -487,7 +487,7 @@ export const v1oauthScenarios: ProxyV1TestData[] = [
authErrorCategory: 'AUTH_STATUS_INACTIVE',
message:
'Campaign Manager: Error transformer proxy v1 during CAMPAIGN_MANAGER response transformation',
status: 500,
status: 403,
},
},
},
Expand All @@ -514,14 +514,14 @@ export const v1oauthScenarios: ProxyV1TestData[] = [
},
output: {
response: {
status: 500,
status: 401,
body: {
output: {
response: [
{
error:
'{"error":"unauthorized","error_description":"Access token expired: 2020-10-20T12:00:00.000Z"}',
statusCode: 500,
statusCode: 401,
metadata: {
jobId: 1,
attemptNum: 1,
Expand Down Expand Up @@ -549,7 +549,7 @@ export const v1oauthScenarios: ProxyV1TestData[] = [
authErrorCategory: 'REFRESH_TOKEN',
message:
'Campaign Manager: Error transformer proxy v1 during CAMPAIGN_MANAGER response transformation',
status: 500,
status: 401,
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ export const otherScenariosV1: ProxyV1TestData[] = [
{
error:
'{"error":{"message":"Service Unavailable","description":"The server is currently unable to handle the request due to temporary overloading or maintenance of the server. Please try again later."}}',
statusCode: 500,
statusCode: 503,
metadata: {
jobId: 1,
attemptNum: 1,
Expand All @@ -287,7 +287,7 @@ export const otherScenariosV1: ProxyV1TestData[] = [
},
message:
'Campaign Manager: Error transformer proxy v1 during CAMPAIGN_MANAGER response transformation',
status: 500,
status: 503,
},
},
},
Expand Down Expand Up @@ -376,7 +376,7 @@ export const otherScenariosV1: ProxyV1TestData[] = [
response: [
{
error: '"Gateway Timeout"',
statusCode: 500,
statusCode: 504,
metadata: {
jobId: 1,
attemptNum: 1,
Expand All @@ -403,7 +403,7 @@ export const otherScenariosV1: ProxyV1TestData[] = [
},
message:
'Campaign Manager: Error transformer proxy v1 during CAMPAIGN_MANAGER response transformation',
status: 500,
status: 504,
},
},
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { testScenariosForV1API } from './oauth';

export const data = [...testScenariosForV1API];
Loading

0 comments on commit b404ef4

Please sign in to comment.