Skip to content

Commit

Permalink
fix: add parsed response in network error (#1704)
Browse files Browse the repository at this point in the history
* fix[gaec]: revert destination response

* fix: authErrorCategory field in the response

Co-authored-by: saikumarrs <saibattinoju@rudderstack.com>
  • Loading branch information
ujjwal-ab and saikumarrs committed Dec 16, 2022
1 parent c343be3 commit 473d384
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const getConversionActionId = async (method, headers, params) => {
response.response?.response?.status
)
},
response,
response.response?.response?.data,
getAuthErrCategory(
get(response, "response.response.status"),
get(response, "response.response.data[0]")
Expand Down
4 changes: 2 additions & 2 deletions src/v0/util/errorTypes/abortedError.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ const tags = require("../tags");
const { BaseError } = require("./base");

class AbortedError extends BaseError {
constructor(message, statusCode = 400, destResponse, authErrCategory) {
constructor(message, statusCode = 400, destResponse, authErrorCategory) {
const finalStatTags = {
[tags.TAG_NAMES.ERROR_CATEGORY]: tags.ERROR_CATEGORIES.NETWORK,
[tags.TAG_NAMES.ERROR_TYPE]: tags.ERROR_TYPES.ABORTED
};

super(message, statusCode, finalStatTags, destResponse, authErrCategory);
super(message, statusCode, finalStatTags, destResponse, authErrorCategory);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/v0/util/errorTypes/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ class BaseError extends Error {
statusCode = 400,
sTags = {},
destResponse = "",
authErrCategory = ""
authErrorCategory = ""
) {
super(message);
this.status = statusCode;
this.statTags = sTags;
this.destinationResponse = destResponse;
this.authErrorCategory = authErrCategory;
this.authErrorCategory = authErrorCategory;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/v0/util/errorTypes/invalidAuthTokenError.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ const tags = require("../tags");
const { BaseError } = require("./base");

class InvalidAuthTokenError extends BaseError {
constructor(message, statusCode = 500, destResponse, authErrCategory) {
constructor(message, statusCode = 500, destResponse, authErrorCategory) {
const finalStatTags = {
[tags.TAG_NAMES.ERROR_CATEGORY]: tags.ERROR_CATEGORIES.NETWORK,
[tags.TAG_NAMES.ERROR_TYPE]: tags.ERROR_TYPES.RETRYABLE,
[tags.TAG_NAMES.META]: tags.METADATA.INVALID_AUTH_TOKEN
};

super(message, statusCode, finalStatTags, destResponse, authErrCategory);
super(message, statusCode, finalStatTags, destResponse, authErrorCategory);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/v0/util/errorTypes/networkError.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class NetworkError extends BaseError {
statusCode = 400,
statTags = {},
destResponse,
authErrCategory
authErrorCategory
) {
const finalStatTags = {
[tags.TAG_NAMES.ERROR_CATEGORY]: tags.ERROR_CATEGORIES.NETWORK,
Expand All @@ -29,7 +29,7 @@ class NetworkError extends BaseError {
}
}

super(message, statusCode, finalStatTags, destResponse, authErrCategory);
super(message, statusCode, finalStatTags, destResponse, authErrorCategory);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/v0/util/errorTypes/retryableError.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ const tags = require("../tags");
const { BaseError } = require("./base");

class RetryableError extends BaseError {
constructor(message, statusCode = 500, destResponse, authErrCategory) {
constructor(message, statusCode = 500, destResponse, authErrorCategory) {
const finalStatTags = {
[tags.TAG_NAMES.ERROR_CATEGORY]: tags.ERROR_CATEGORIES.NETWORK,
[tags.TAG_NAMES.ERROR_TYPE]: tags.ERROR_TYPES.RETRYABLE
};

super(message, statusCode, finalStatTags, destResponse, authErrCategory);
super(message, statusCode, finalStatTags, destResponse, authErrorCategory);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/v0/util/errorTypes/transformationError.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ const tags = require("../tags");
const { BaseError } = require("./base");

class TransformationError extends BaseError {
constructor(message, statusCode = 400, destResponse, authErrCategory) {
constructor(message, statusCode = 400, destResponse, authErrorCategory) {
const finalStatTags = {
[tags.TAG_NAMES.ERROR_CATEGORY]: tags.ERROR_CATEGORIES.TRANSFORMATION
};

super(message, statusCode, finalStatTags, destResponse, authErrCategory);
super(message, statusCode, finalStatTags, destResponse, authErrorCategory);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/v0/util/errorTypes/unauthorizedError.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ const tags = require("../tags");
const { BaseError } = require("./base");

class UnauthorizedError extends BaseError {
constructor(message, statusCode = 400, destResponse, authErrCategory) {
constructor(message, statusCode = 400, destResponse, authErrorCategory) {
const finalStatTags = {
[tags.TAG_NAMES.ERROR_CATEGORY]: tags.ERROR_CATEGORIES.NETWORK,
[tags.TAG_NAMES.ERROR_TYPE]: tags.ERROR_TYPES.ABORTED,
[tags.TAG_NAMES.META]: tags.METADATA.UNAUTHORIZED
};

super(message, statusCode, finalStatTags, destResponse, authErrCategory);
super(message, statusCode, finalStatTags, destResponse, authErrorCategory);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/versionedRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -1027,8 +1027,8 @@ async function handleProxyRequest(destination, ctx) {

response = {
status: errObj.status,
...(errObj.authErrCategory && {
authErrCategory: errObj.authErrorCategory
...(errObj.authErrorCategory && {
authErrorCategory: errObj.authErrorCategory
}),
destinationResponse: errObj.destinationResponse,
message: errObj.message,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,26 @@
[
{
"output": {
"status": 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.\" during Google_adwords_enhanced_conversions response transformation",
"destinationResponse": {
"response": {
"response": {
"data": [
{
"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"
}
}
],
"status": 401
"authErrorCategory": "REFRESH_TOKEN",
"destinationResponse": [
{
"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"
}
},
"success": false
},
}
],
"statTags": {
"destType": "GOOGLE_ADWORDS_ENHANCED_CONVERSIONS",
"errorCategory": "network",
"errorType": "aborted",
"feature": "dataDelivery",
"implementation": "native",
"module": "destination"
}
},
"status": 401
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"output": {
"status": 401,
"message": "[Google Ads Offline Conversions]:: 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 google_ads_offline_conversions response transformation",
"authErrorCategory": "REFRESH_TOKEN",
"destinationResponse": [
{
"error": {
Expand Down
1 change: 1 addition & 0 deletions test/__tests__/data/pardot_proxy_output.json
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@
"output": {
"message": "access_token is invalid, unknown, or malformed: Inactive token during Pardot response transformation",
"status": 500,
"authErrorCategory": "REFRESH_TOKEN",
"destinationResponse": {
"@attributes": {
"stat": "fail",
Expand Down

0 comments on commit 473d384

Please sign in to comment.