Skip to content

Commit

Permalink
chore(release): pull hotfix-release/v1.76.1 into main (#3691)
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsSudip authored Aug 29, 2024
2 parents df66241 + 4a1dcbf commit ed4a1a6
Show file tree
Hide file tree
Showing 6 changed files with 178 additions and 14 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.76.1](https://github.com/rudderlabs/rudder-transformer/compare/v1.76.0...v1.76.1) (2024-08-29)


### Bug Fixes

* reddit authorisation failed case handling ([#3690](https://github.com/rudderlabs/rudder-transformer/issues/3690)) ([f24759a](https://github.com/rudderlabs/rudder-transformer/commit/f24759aebbeb560f0de9d4920ae2ed0cdc7bfa3f))

## [1.76.0](https://github.com/rudderlabs/rudder-transformer/compare/v1.75.1...v1.76.0) (2024-08-20)


Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rudder-transformer",
"version": "1.76.0",
"version": "1.76.1",
"description": "",
"homepage": "https://github.com/rudderlabs/rudder-transformer#readme",
"bugs": {
Expand Down
20 changes: 16 additions & 4 deletions src/v0/destinations/reddit/networkHandler.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { RetryableError } = require('@rudderstack/integrations-lib');
const isString = require('lodash/isString');
const { prepareProxyRequest, proxyRequest } = require('../../../adapters/network');
const { isHttpStatusSuccess } = require('../../util/index');
const { REFRESH_TOKEN } = require('../../../adapters/networkhandler/authConstants');
Expand All @@ -9,12 +10,23 @@ const redditRespHandler = (destResponse) => {
const { status, response } = destResponse;

// to handle the case when authorization-token is invalid
if (status === 401 && response.includes('Authorization Required')) {
if (status === 401) {
let errorMessage = 'Authorization failed';
let authErrorCategory = '';

if (isString(response) && response.includes('Authorization Required')) {
errorMessage = `Request failed due to ${response}`;
authErrorCategory = REFRESH_TOKEN;
} else if (response?.error?.reason === 'UNAUTHORIZED') {
errorMessage = response.error.explanation || errorMessage;
authErrorCategory = REFRESH_TOKEN;
}

throw new RetryableError(
`Request failed due to ${response} 'during reddit response transformation'`,
500,
`${errorMessage} during reddit response transformation`,
status,
destResponse,
REFRESH_TOKEN,
authErrorCategory,
);
}
};
Expand Down
102 changes: 95 additions & 7 deletions test/integrations/destinations/reddit/dataDelivery/oauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const v0oauthScenarios = [
},
output: {
response: {
status: 500,
status: 401,
body: {
output: {
authErrorCategory: 'REFRESH_TOKEN',
Expand All @@ -90,9 +90,53 @@ export const v0oauthScenarios = [
status: 401,
},
message:
"Request failed due to Authorization Required 'during reddit response transformation'",
'Request failed due to Authorization Required during reddit response transformation',
statTags: expectedStatTags,
status: 500,
status: 401,
},
},
},
},
},
{
id: 'reddit_v0_oauth_scenario_2',
name: 'reddit',
description: '[Proxy v0 API] :: Oauth where error response is an object from destination',
successCriteria: 'Should return 401 with authErrorCategory as REFRESH_TOKEN',
scenario: 'Oauth',
feature: 'dataDelivery',
module: 'destination',
version: 'v0',
input: {
request: {
body: generateProxyV0Payload({
...commonRequestParameters,
endpoint: 'https://ads-api.reddit.com/api/v2.0/conversions/events/a2_objResp_401',
}),
method: 'POST',
},
},
output: {
response: {
status: 401,
body: {
output: {
authErrorCategory: 'REFRESH_TOKEN',
destinationResponse: {
response: {
success: false,
error: {
reason: 'UNAUTHORIZED',
explanation:
'This server could not verify that you are authorized to access the document you requested.',
},
},
status: 401,
},
message:
'This server could not verify that you are authorized to access the document you requested. during reddit response transformation',
statTags: expectedStatTags,
status: 401,
},
},
},
Expand Down Expand Up @@ -124,21 +168,65 @@ export const v1oauthScenarios = [
},
output: {
response: {
status: 500,
status: 401,
body: {
output: {
authErrorCategory: 'REFRESH_TOKEN',
message:
"Request failed due to Authorization Required 'during reddit response transformation'",
'Request failed due to Authorization Required during reddit response transformation',
response: [
{
error: '"Authorization Required"',
metadata: generateMetadata(1),
statusCode: 500,
statusCode: 401,
},
],
statTags: expectedStatTags,
status: 401,
},
},
},
},
},
{
id: 'reddit_v1_oauth_scenario_2',
name: 'reddit',
description: '[Proxy v1 API] :: Oauth where error response is an object from destination',
successCriteria: 'Should return 401 with authErrorCategory as REFRESH_TOKEN',
scenario: 'Oauth',
feature: 'dataDelivery',
module: 'destination',
version: 'v1',
input: {
request: {
body: generateProxyV1Payload(
{
...commonRequestParameters,
endpoint: 'https://ads-api.reddit.com/api/v2.0/conversions/events/a2_objResp_401',
},
[generateMetadata(1)],
),
method: 'POST',
},
},
output: {
response: {
status: 401,
body: {
output: {
authErrorCategory: 'REFRESH_TOKEN',
message:
'This server could not verify that you are authorized to access the document you requested. during reddit response transformation',
response: [
{
error:
'{"success":false,"error":{"reason":"UNAUTHORIZED","explanation":"This server could not verify that you are authorized to access the document you requested."}}',
metadata: generateMetadata(1),
statusCode: 401,
},
],
statTags: expectedStatTags,
status: 500,
status: 401,
},
},
},
Expand Down
57 changes: 57 additions & 0 deletions test/integrations/destinations/reddit/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,61 @@ export const networkCallsData = [
},
httpRes: { data: 'Authorization Required', status: 401, statusText: 'Unauthorized' },
},
{
httpReq: {
url: 'https://ads-api.reddit.com/api/v2.0/conversions/events/a2_objResp_401',
data: {
events: [
{
event_at: '2019-10-14T09:03:17.562Z',
event_type: {
tracking_type: 'ViewContent',
},
user: {
aaid: 'c12d34889302d3c656b5699fa9190b51c50d6f62fce57e13bd56b503d66c487a',
email: 'ac144532d9e4efeab19475d9253a879173ea12a3d2238d1cb8a332a7b3a105f2',
external_id: '7b023241a3132b792a5a33915a5afb3133cbb1e13d72879689bf6504de3b036d',
ip_address: 'e80bd55a3834b7c2a34ade23c7ecb54d2a49838227080f50716151e765a619db',
user_agent:
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36',
screen_dimensions: {},
},
event_metadata: {
item_count: 3,
products: [
{
id: '123',
name: 'Monopoly',
category: 'Games',
},
{
id: '345',
name: 'UNO',
category: 'Games',
},
],
},
},
],
},
params: { destination: 'reddit' },
headers: {
Authorization: 'Bearer dummyAccessToken',
'Content-Type': 'application/json',
},
method: 'POST',
},
httpRes: {
data: {
success: false,
error: {
reason: 'UNAUTHORIZED',
explanation:
'This server could not verify that you are authorized to access the document you requested.',
},
},
status: 401,
statusText: 'Unauthorized',
},
},
];

0 comments on commit ed4a1a6

Please sign in to comment.