Skip to content

Commit

Permalink
fix: review comments addressed
Browse files Browse the repository at this point in the history
  • Loading branch information
shrouti1507 committed Nov 13, 2023
1 parent 8c89d89 commit 932ee94
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
13 changes: 2 additions & 11 deletions src/v0/destinations/salesforce/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const {
identifyContactMappingJson,
ignoredLeadTraits,
ignoredContactTraits,
OAUTH,
} = require('./config');
const {
removeUndefinedValues,
Expand Down Expand Up @@ -112,15 +111,11 @@ async function getSaleforceIdForRecord(
authorizationFlow,
) {
const objSearchUrl = `${authorizationData.instanceUrl}/services/data/v${SF_API_VERSION}/parameterizedSearch/?q=${identifierValue}&sobject=${objectType}&in=${identifierType}&${objectType}.fields=id,${identifierType}`;
const finalHeader =
authorizationFlow === OAUTH
? { Authorization: `Bearer ${authorizationData.token}` }
: { Authorization: authorizationData.token };
const { processedResponse: processedsfSearchResponse } = await handleHttpRequest(
'get',
objSearchUrl,
{
headers: finalHeader,
headers: getAuthHeader({ authorizationFlow, authorizationData }),
},
{
destType: 'salesforce',
Expand Down Expand Up @@ -227,17 +222,13 @@ async function getSalesforceIdFromPayload(
throw new InstrumentationError('Invalid Email address for Lead Objet');
}
const leadQueryUrl = `${authorizationData.instanceUrl}/services/data/v${SF_API_VERSION}/parameterizedSearch/?q=${email}&sobject=Lead&Lead.fields=id,IsConverted,ConvertedContactId,IsDeleted`;
const finalHeader =
authorizationFlow === OAUTH
? { Authorization: `Bearer ${authorizationData.token}` }
: { Authorization: authorizationData.token };

// request configuration will be conditional
const { processedResponse: processedLeadQueryResponse } = await handleHttpRequest(
'get',
leadQueryUrl,
{
headers: finalHeader,
headers: getAuthHeader({ authorizationFlow, authorizationData }),
},
{
destType: 'salesforce',
Expand Down
2 changes: 1 addition & 1 deletion src/v0/destinations/salesforce/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const salesforceResponseHandler = (destResponse, sourceMessage, authKey, authori
throw new RetryableError(
`${DESTINATION} Request Failed - due to "INVALID_SESSION_ID", (Retryable) ${sourceMessage}`,
500,
response,
destResponse,
authorizationFlow === LEGACY ? '' : getAuthErrCategoryFromStCode(status),
);
} else if (status === 403 && matchErrorCode('REQUEST_LIMIT_EXCEEDED')) {
Expand Down
18 changes: 13 additions & 5 deletions test/integrations/destinations/salesforce/dataDelivery/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,20 @@ export const data = [
authErrorCategory: 'REFRESH_TOKEN',
message:
'Salesforce Request Failed - due to "INVALID_SESSION_ID", (Retryable) during Salesforce Response Handling',
destinationResponse: [
{
message: 'Session expired or invalid',
errorCode: 'INVALID_SESSION_ID',
destinationResponse: {
response: [
{
message: 'Session expired or invalid',
errorCode: 'INVALID_SESSION_ID',
},
],
rudderJobMetadata: {
destInfo: {
authKey: '2HezPl1w11opbFSxnLDEgZ7kWTf',
},
},
],
status: 401,
},
statTags: {
destType: 'SALESFORCE',
errorCategory: 'network',
Expand Down

0 comments on commit 932ee94

Please sign in to comment.