Skip to content

Commit

Permalink
Merge branch 'main' of github.com:rudderlabs/rudder-transformer into …
Browse files Browse the repository at this point in the history
…chore.merge.main
  • Loading branch information
krishna2020 committed Dec 5, 2023
2 parents 7910dba + e04cedd commit e48eda6
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 9 deletions.
57 changes: 57 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -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

<hr>

### 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.
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.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)


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.50.0",
"version": "1.50.1",
"description": "",
"homepage": "https://github.com/rudderlabs/rudder-transformer#readme",
"bugs": {
Expand Down
2 changes: 2 additions & 0 deletions src/v0/destinations/salesforce/networkHandler.js
Original file line number Diff line number Diff line change
@@ -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) => {
Expand All @@ -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
Expand Down
15 changes: 10 additions & 5 deletions src/v0/destinations/salesforce/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(

Check warning on line 37 in src/v0/destinations/salesforce/utils.js

View check run for this annotation

Codecov / codecov/patch

src/v0/destinations/salesforce/utils.js#L37

Added line #L37 was not covered by tests
`${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.
Expand Down
33 changes: 33 additions & 0 deletions src/v0/destinations/salesforce_oauth/networkHandler.js
Original file line number Diff line number Diff line change
@@ -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`;

Check warning on line 7 in src/v0/destinations/salesforce_oauth/networkHandler.js

View check run for this annotation

Codecov / codecov/patch

src/v0/destinations/salesforce_oauth/networkHandler.js#L7

Added line #L7 was not covered by tests

salesforceResponseHandler(

Check warning on line 9 in src/v0/destinations/salesforce_oauth/networkHandler.js

View check run for this annotation

Codecov / codecov/patch

src/v0/destinations/salesforce_oauth/networkHandler.js#L9

Added line #L9 was not covered by tests
destinationResponse,
'during Salesforce Response Handling',
destinationResponse?.rudderJobMetadata?.destInfo?.authKey,
OAUTH
);

// else successfully return status as 200, message and original destination response
return {

Check warning on line 17 in src/v0/destinations/salesforce_oauth/networkHandler.js

View check run for this annotation

Codecov / codecov/patch

src/v0/destinations/salesforce_oauth/networkHandler.js#L17

Added line #L17 was not covered by tests
status: 200,
message,
destinationResponse,
};
};

function networkHandler() {
this.responseHandler = responseHandler;
this.proxy = proxyRequest;
this.prepareProxy = prepareProxyRequest;
this.processAxiosResponse = processAxiosResponse;

Check warning on line 28 in src/v0/destinations/salesforce_oauth/networkHandler.js

View check run for this annotation

Codecov / codecov/patch

src/v0/destinations/salesforce_oauth/networkHandler.js#L24-L28

Added lines #L24 - L28 were not covered by tests
}

module.exports = {
networkHandler,
};
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit e48eda6

Please sign in to comment.