diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000000..5b716b7e9f --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,57 @@ +## What are the changes introduced in this PR? + +Write a brief explainer on your code changes. + +## Please explain the objectives of your changes below + +Put down any required details on the broader aspect of your changes. If there are any dependent changes, **mandatorily** mention them here + +### Type of change + +If the pull request is a **bug-fix**, **enhancement** or a **refactor**, please fill in the details on the changes made. + +- Existing capabilities/behavior + +- New capabilities/behavior + +If the pull request is a **new feature**, + +### Any technical or performance related pointers to consider with the change? + +N/A + +### Any new dependencies introduced with this change? + +N/A + +### Any new generic utility introduced or modified. Please explain the changes. + +N/A + +### If the PR has changes in more than 10 files, please mention why the changes were not split into multiple PRs. + +N/A + +### If multiple linear tasks are associated with the PR changes, please elaborate on the reason: + +N/A + +
+ +### Developer checklist + +- [ ] **No breaking changes are being introduced.** + +- [ ] Are all related docs linked with the PR? + +- [ ] Are all changes manually tested? + +- [ ] Does this change require any documentation changes? + +- [ ] Are relevant unit and component test-cases added? + +### Reviewer checklist + +- [ ] Is the type of change in the PR title appropriate as per the changes? + +- [ ] Verified that there are no credentials or confidential data exposed with the changes. diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f990fe3b9..10f456d480 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.50.1](https://github.com/rudderlabs/rudder-transformer/compare/v1.50.0...v1.50.1) (2023-12-05) + + +### Bug Fixes + +* salesforce transformer proxy response handling issue for authorization flow ([#2873](https://github.com/rudderlabs/rudder-transformer/issues/2873)) ([4cec65e](https://github.com/rudderlabs/rudder-transformer/commit/4cec65e4103e99021f5108fcc7c557b952f1c5eb)) + ## [1.50.0](https://github.com/rudderlabs/rudder-transformer/compare/v1.49.1...v1.50.0) (2023-11-13) diff --git a/package-lock.json b/package-lock.json index 28d814c925..94246d066b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rudder-transformer", - "version": "1.50.0", + "version": "1.50.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rudder-transformer", - "version": "1.50.0", + "version": "1.50.1", "license": "ISC", "dependencies": { "@amplitude/ua-parser-js": "^0.7.24", diff --git a/package.json b/package.json index e4a4d9151c..60fb93acc4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rudder-transformer", - "version": "1.50.0", + "version": "1.50.1", "description": "", "homepage": "https://github.com/rudderlabs/rudder-transformer#readme", "bugs": { diff --git a/src/v0/destinations/salesforce/networkHandler.js b/src/v0/destinations/salesforce/networkHandler.js index 622d2ae731..dc67aff1b7 100644 --- a/src/v0/destinations/salesforce/networkHandler.js +++ b/src/v0/destinations/salesforce/networkHandler.js @@ -1,5 +1,6 @@ const { proxyRequest, prepareProxyRequest } = require('../../../adapters/network'); const { processAxiosResponse } = require('../../../adapters/utils/networkUtils'); +const { LEGACY } = require('./config'); const { salesforceResponseHandler } = require('./utils'); const responseHandler = (destinationResponse, destType) => { @@ -9,6 +10,7 @@ const responseHandler = (destinationResponse, destType) => { destinationResponse, 'during Salesforce Response Handling', destinationResponse?.rudderJobMetadata?.destInfo?.authKey, + LEGACY ); // else successfully return status as 200, message and original destination response diff --git a/src/v0/destinations/salesforce/utils.js b/src/v0/destinations/salesforce/utils.js index c725ec3b20..96735ecc17 100644 --- a/src/v0/destinations/salesforce/utils.js +++ b/src/v0/destinations/salesforce/utils.js @@ -33,16 +33,21 @@ const salesforceResponseHandler = (destResponse, sourceMessage, authKey, authori const matchErrorCode = (errorCode) => response && Array.isArray(response) && response.some((resp) => resp?.errorCode === errorCode); if (status === 401 && authKey && matchErrorCode('INVALID_SESSION_ID')) { - if (authorizationFlow === LEGACY) { - // checking for invalid/expired token errors and evicting cache in that case - // rudderJobMetadata contains some destination info which is being used to evict the cache - ACCESS_TOKEN_CACHE.del(authKey); + if (authorizationFlow === OAUTH) { + throw new RetryableError( + `${DESTINATION} Request Failed - due to "INVALID_SESSION_ID", (Retryable) ${sourceMessage}`, + 500, + destResponse, + getAuthErrCategoryFromStCode(status), + ); } + // checking for invalid/expired token errors and evicting cache in that case + // rudderJobMetadata contains some destination info which is being used to evict the cache + ACCESS_TOKEN_CACHE.del(authKey); throw new RetryableError( `${DESTINATION} Request Failed - due to "INVALID_SESSION_ID", (Retryable) ${sourceMessage}`, 500, destResponse, - authorizationFlow === LEGACY ? '' : getAuthErrCategoryFromStCode(status), ); } else if (status === 403 && matchErrorCode('REQUEST_LIMIT_EXCEEDED')) { // If the error code is REQUEST_LIMIT_EXCEEDED, you’ve exceeded API request limits in your org. diff --git a/src/v0/destinations/salesforce_oauth/networkHandler.js b/src/v0/destinations/salesforce_oauth/networkHandler.js new file mode 100644 index 0000000000..2042830cb1 --- /dev/null +++ b/src/v0/destinations/salesforce_oauth/networkHandler.js @@ -0,0 +1,33 @@ +const { proxyRequest, prepareProxyRequest } = require('../../../adapters/network'); +const { processAxiosResponse } = require('../../../adapters/utils/networkUtils'); +const { OAUTH } = require('../salesforce/config'); +const { salesforceResponseHandler } = require('../salesforce/utils'); + +const responseHandler = (destinationResponse, destType) => { + const message = `Request for destination: ${destType} Processed Successfully`; + + salesforceResponseHandler( + destinationResponse, + 'during Salesforce Response Handling', + destinationResponse?.rudderJobMetadata?.destInfo?.authKey, + OAUTH + ); + + // else successfully return status as 200, message and original destination response + return { + status: 200, + message, + destinationResponse, + }; +}; + +function networkHandler() { + this.responseHandler = responseHandler; + this.proxy = proxyRequest; + this.prepareProxy = prepareProxyRequest; + this.processAxiosResponse = processAxiosResponse; +} + +module.exports = { + networkHandler, +}; diff --git a/test/__tests__/facebook_conversions.test.js b/test/__tests__/facebook_conversions.test.js index a450952efe..9495a85913 100644 --- a/test/__tests__/facebook_conversions.test.js +++ b/test/__tests__/facebook_conversions.test.js @@ -23,6 +23,8 @@ const outputRouterDataFile = fs.readFileSync( const inputRouterData = JSON.parse(inputRouterDataFile); const expectedRouterData = JSON.parse(outputRouterDataFile); +Date.now = jest.fn(() => new Date("2023-11-12T15:46:51.000Z")); // 2023-11-12T15:46:51.693229+05:30 + describe(`${name} Tests`, () => { describe("Processor", () => { testData.forEach((dataPoint, index) => { diff --git a/test/integrations/destinations/salesforce/dataDelivery/data.ts b/test/integrations/destinations/salesforce/dataDelivery/data.ts index c53ce58f9e..2f1e04815b 100644 --- a/test/integrations/destinations/salesforce/dataDelivery/data.ts +++ b/test/integrations/destinations/salesforce/dataDelivery/data.ts @@ -119,7 +119,6 @@ export const data = [ body: { output: { status: 500, - authErrorCategory: 'REFRESH_TOKEN', message: 'Salesforce Request Failed - due to "INVALID_SESSION_ID", (Retryable) during Salesforce Response Handling', destinationResponse: {