From feadfcf6009ccc9b972634347448ba9428696ebb Mon Sep 17 00:00:00 2001 From: Sudip Paul <67197965+ItsSudip@users.noreply.github.com> Date: Fri, 2 Aug 2024 12:04:27 +0530 Subject: [PATCH 1/2] fix: update getAuthErrCategory and update error message for garl (#3629) * fix: update getAuthErrCategory and update error message for garl * chore: address comment --- .../networkHandler.js | 2 +- src/v0/util/googleUtils/index.js | 6 +- .../dataDelivery/business.ts | 6 +- .../dataDelivery/oauth.ts | 74 +++++++++++++++---- .../network.ts | 48 ++++++++++++ 5 files changed, 117 insertions(+), 19 deletions(-) diff --git a/src/v0/destinations/google_adwords_remarketing_lists/networkHandler.js b/src/v0/destinations/google_adwords_remarketing_lists/networkHandler.js index 98659fdf88..6491215a93 100644 --- a/src/v0/destinations/google_adwords_remarketing_lists/networkHandler.js +++ b/src/v0/destinations/google_adwords_remarketing_lists/networkHandler.js @@ -153,7 +153,7 @@ const gaAudienceRespHandler = (destResponse, stageMsg) => { // const { stat, err_code: errorCode } = respAttributes; throw new NetworkError( - `${response?.error?.message} ${stageMsg}`, + `${JSON.stringify(response)} ${stageMsg}`, status, { [tags.TAG_NAMES.ERROR_TYPE]: getDynamicErrorType(status), diff --git a/src/v0/util/googleUtils/index.js b/src/v0/util/googleUtils/index.js index 406afa1a49..124f63eda5 100644 --- a/src/v0/util/googleUtils/index.js +++ b/src/v0/util/googleUtils/index.js @@ -121,8 +121,12 @@ const getAuthErrCategory = ({ response, status }) => { const authenticationError = respArr.map((resp) => get(resp, 'error.details.0.errors.0.errorCode.authenticationError'), ); - if (authenticationError.includes('TWO_STEP_VERIFICATION_NOT_ENROLLED')) { + if ( // https://developers.google.com/google-ads/api/docs/oauth/2sv + authenticationError.includes('TWO_STEP_VERIFICATION_NOT_ENROLLED') || + // https://developers.google.com/google-ads/api/docs/common-errors#:~:text=this%20for%20you.-,CUSTOMER_NOT_FOUND,-Summary + authenticationError.includes('CUSTOMER_NOT_FOUND') + ) { return AUTH_STATUS_INACTIVE; } return REFRESH_TOKEN; diff --git a/test/integrations/destinations/google_adwords_remarketing_lists/dataDelivery/business.ts b/test/integrations/destinations/google_adwords_remarketing_lists/dataDelivery/business.ts index ed1741e939..c0d8454548 100644 --- a/test/integrations/destinations/google_adwords_remarketing_lists/dataDelivery/business.ts +++ b/test/integrations/destinations/google_adwords_remarketing_lists/dataDelivery/business.ts @@ -166,7 +166,7 @@ export const testScenariosForV0API = [ output: { status: 400, message: - 'Request contains an invalid argument. during ga_audience response transformation', + '{"error":{"code":400,"details":[{"@type":"type.googleapis.com/google.ads.googleads.v9.errors.GoogleAdsFailure","errors":[{"errorCode":{"offlineUserDataJobError":"INVALID_SHA256_FORMAT"},"message":"The SHA256 encoded value is malformed.","location":{"fieldPathElements":[{"fieldName":"operations","index":0},{"fieldName":"remove"},{"fieldName":"user_identifiers","index":0},{"fieldName":"hashed_email"}]}}]}],"message":"Request contains an invalid argument.","status":"INVALID_ARGUMENT"}} during ga_audience response transformation', destinationResponse: { error: { code: 400, @@ -313,11 +313,11 @@ export const testScenariosForV1API = [ body: { output: { message: - 'Request contains an invalid argument. during ga_audience response transformation', + '{"error":{"code":400,"details":[{"@type":"type.googleapis.com/google.ads.googleads.v9.errors.GoogleAdsFailure","errors":[{"errorCode":{"offlineUserDataJobError":"INVALID_SHA256_FORMAT"},"message":"The SHA256 encoded value is malformed.","location":{"fieldPathElements":[{"fieldName":"operations","index":0},{"fieldName":"remove"},{"fieldName":"user_identifiers","index":0},{"fieldName":"hashed_email"}]}}]}],"message":"Request contains an invalid argument.","status":"INVALID_ARGUMENT"}} during ga_audience response transformation', response: [ { error: - 'Request contains an invalid argument. during ga_audience response transformation', + '{"error":{"code":400,"details":[{"@type":"type.googleapis.com/google.ads.googleads.v9.errors.GoogleAdsFailure","errors":[{"errorCode":{"offlineUserDataJobError":"INVALID_SHA256_FORMAT"},"message":"The SHA256 encoded value is malformed.","location":{"fieldPathElements":[{"fieldName":"operations","index":0},{"fieldName":"remove"},{"fieldName":"user_identifiers","index":0},{"fieldName":"hashed_email"}]}}]}],"message":"Request contains an invalid argument.","status":"INVALID_ARGUMENT"}} during ga_audience response transformation', metadata: generateGoogleOAuthMetadata(1), statusCode: 400, }, diff --git a/test/integrations/destinations/google_adwords_remarketing_lists/dataDelivery/oauth.ts b/test/integrations/destinations/google_adwords_remarketing_lists/dataDelivery/oauth.ts index b7f93a6945..9fd695a7a3 100644 --- a/test/integrations/destinations/google_adwords_remarketing_lists/dataDelivery/oauth.ts +++ b/test/integrations/destinations/google_adwords_remarketing_lists/dataDelivery/oauth.ts @@ -1,5 +1,16 @@ -import { generateProxyV1Payload } from '../../../testUtils'; -import { commonHeaders, commonParams, expectedStatTags, validRequestPayload1 } from './business'; +import { generateMetadata, generateProxyV1Payload } from '../../../testUtils'; +import { commonHeaders, commonParams, validRequestPayload1 } from './business'; + +const commonStatTags = { + destType: 'GOOGLE_ADWORDS_REMARKETING_LISTS', + destinationId: 'default-destinationId', + errorCategory: 'network', + errorType: 'aborted', + feature: 'dataDelivery', + implementation: 'native', + module: 'destination', + workspaceId: 'default-workspaceId', +}; export const oauthError = [ { @@ -31,11 +42,11 @@ export const oauthError = [ output: { authErrorCategory: 'REFRESH_TOKEN', message: - 'Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project. during ga_audience response transformation', + '{"error":{"code":401,"message":"Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.","status":"UNAUTHENTICATED"}} during ga_audience response transformation', response: [ { error: - 'Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project. during ga_audience response transformation', + '{"error":{"code":401,"message":"Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.","status":"UNAUTHENTICATED"}} during ga_audience response transformation', metadata: { attemptNum: 1, destinationId: 'default-destinationId', @@ -51,16 +62,51 @@ export const oauthError = [ statusCode: 401, }, ], - statTags: { - destType: 'GOOGLE_ADWORDS_REMARKETING_LISTS', - destinationId: 'default-destinationId', - errorCategory: 'network', - errorType: 'aborted', - feature: 'dataDelivery', - implementation: 'native', - module: 'destination', - workspaceId: 'default-workspaceId', - }, + statTags: commonStatTags, + status: 401, + }, + }, + }, + }, + }, + { + id: 'garl_oauth_scenario_with_wrong_customer_id', + name: 'google_adwords_remarketing_lists', + description: '[Proxy v1 API] :: Oauth where customer has provided wrong customerId', + successCriteria: 'The proxy should return 401 with authErrorCategory as AUTH_STATUS_INACTIVE', + scenario: 'Oauth', + feature: 'dataDelivery', + module: 'destination', + version: 'v1', + input: { + request: { + body: generateProxyV1Payload({ + headers: { ...commonHeaders, Authorization: 'Bearer wrongCustomerID' }, + params: { ...commonParams, customerId: 'wrongCustomerID' }, + JSON: validRequestPayload1, + endpoint: 'https://googleads.googleapis.com/v16/customers/customerid/offlineUserDataJobs', + accessToken: 'wrongCustomerID', + }), + method: 'POST', + }, + }, + output: { + response: { + status: 401, + body: { + output: { + authErrorCategory: 'AUTH_STATUS_INACTIVE', + message: + '{"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.","status":"UNAUTHENTICATED","details":[{"@type":"type.googleapis.com/google.ads.googleads.v16.errors.GoogleAdsFailure","errors":[{"errorCode":{"authenticationError":"CUSTOMER_NOT_FOUND"},"message":"No customer found for the provided customer id."}],"requestId":"lvB3KOjGHsgduHjt0wCglQ"}]}} during ga_audience response transformation', + 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.","status":"UNAUTHENTICATED","details":[{"@type":"type.googleapis.com/google.ads.googleads.v16.errors.GoogleAdsFailure","errors":[{"errorCode":{"authenticationError":"CUSTOMER_NOT_FOUND"},"message":"No customer found for the provided customer id."}],"requestId":"lvB3KOjGHsgduHjt0wCglQ"}]}} during ga_audience response transformation', + metadata: { ...generateMetadata(1), secret: { accessToken: 'wrongCustomerID' } }, + statusCode: 401, + }, + ], + statTags: commonStatTags, status: 401, }, }, diff --git a/test/integrations/destinations/google_adwords_remarketing_lists/network.ts b/test/integrations/destinations/google_adwords_remarketing_lists/network.ts index 1fd95858a1..d17f518c46 100644 --- a/test/integrations/destinations/google_adwords_remarketing_lists/network.ts +++ b/test/integrations/destinations/google_adwords_remarketing_lists/network.ts @@ -241,4 +241,52 @@ export const networkCallsData = [ }, }, }, + { + httpReq: { + url: 'https://googleads.googleapis.com/v16/customers/customerid/offlineUserDataJobs:create', + data: { + job: { + type: 'CUSTOMER_MATCH_USER_LIST', + customerMatchUserListMetadata: { + userList: 'customers/wrongCustomerID/userLists/709078448', + consent: { + adPersonalization: 'UNSPECIFIED', + adUserData: 'UNSPECIFIED', + }, + }, + }, + }, + headers: { + Authorization: 'Bearer wrongCustomerID', + 'Content-Type': 'application/json', + 'developer-token': 'dummy-dev-token', + }, + method: 'POST', + }, + httpRes: { + status: 401, + data: { + 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.', + status: 'UNAUTHENTICATED', + details: [ + { + '@type': 'type.googleapis.com/google.ads.googleads.v16.errors.GoogleAdsFailure', + errors: [ + { + errorCode: { + authenticationError: 'CUSTOMER_NOT_FOUND', + }, + message: 'No customer found for the provided customer id.', + }, + ], + requestId: 'lvB3KOjGHsgduHjt0wCglQ', + }, + ], + }, + }, + }, + }, ]; From 930ff9baf02d0ba72298e67610cf34034fb27e28 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Fri, 2 Aug 2024 06:38:40 +0000 Subject: [PATCH 2/2] chore(release): 1.73.1 --- CHANGELOG.md | 7 +++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 132bff6f10..254c780be8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [1.73.1](https://github.com/rudderlabs/rudder-transformer/compare/v1.73.0...v1.73.1) (2024-08-02) + + +### Bug Fixes + +* update getAuthErrCategory and update error message for garl ([#3629](https://github.com/rudderlabs/rudder-transformer/issues/3629)) ([feadfcf](https://github.com/rudderlabs/rudder-transformer/commit/feadfcf6009ccc9b972634347448ba9428696ebb)) + ## [1.73.0](https://github.com/rudderlabs/rudder-transformer/compare/v1.72.2...v1.73.0) (2024-07-31) diff --git a/package-lock.json b/package-lock.json index 5433e52331..f6eb14f92f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rudder-transformer", - "version": "1.73.0", + "version": "1.73.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rudder-transformer", - "version": "1.73.0", + "version": "1.73.1", "license": "ISC", "dependencies": { "@amplitude/ua-parser-js": "0.7.24", diff --git a/package.json b/package.json index 01f2d39470..79488e860a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rudder-transformer", - "version": "1.73.0", + "version": "1.73.1", "description": "", "homepage": "https://github.com/rudderlabs/rudder-transformer#readme", "bugs": {