Skip to content

fix: parameterizedSearch to return the exact match - #2428

Merged
yashasvibajpai merged 6 commits into
developfrom
fix.salesforce.parameterized.search
Aug 9, 2023
Merged

yashasvibajpai merged 6 commits into
developfrom
fix.salesforce.parameterized.search

Conversation

@yashasvibajpai

Copy link
Copy Markdown
Contributor

Description of the change

Description here

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Related issues

Fix #1

Checklists

Development

  • Lint rules pass locally
  • The code changed/added as part of this pull request has been covered with tests
  • All tests related to the changed code pass in development

Code review

  • This pull request has a descriptive title and information useful to a reviewer. There may be a screenshot or screencast attached
  • "Ready for review" label attached to the PR and reviewers mentioned in a comment
  • Changes have been reviewed by at least one other engineer
  • Issue from task tracker has a link to this pull request

@yashasvibajpai
yashasvibajpai requested a review from a team as a code owner August 3, 2023 18:20
@yashasvibajpai yashasvibajpai self-assigned this Aug 3, 2023
@codecov

codecov Bot commented Aug 3, 2023 •

Copy link
Copy Markdown

Codecov Report

Patch coverage: 12.50% and project coverage change: -0.02% ⚠️

Comparison is base (b774172) 86.60% compared to head (80e6192) 86.59%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2428      +/-   ##
===========================================
- Coverage    86.60%   86.59%   -0.02%     
===========================================
  Files          556      556              
  Lines        27775    27781       +6     
  Branches      6652     6653       +1     
===========================================
+ Hits         24055    24056       +1     
- Misses        3365     3369       +4     
- Partials       355      356       +1     
Files Changed Coverage Δ
src/v0/destinations/salesforce/transform.js 79.25% <12.50%> (-2.92%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sanpj2292

sanpj2292 commented Aug 3, 2023 •

Copy link
Copy Markdown

We should probably handle the case where the id returned is undefined. let's think through that scenario as well

mihir-4116
mihir-4116 previously approved these changes Aug 4, 2023
@sanpj2292

sanpj2292 commented Aug 4, 2023 •

Copy link
Copy Markdown

Let's add the test-case(s) that describe the scenario we got

@sanpj2292 sanpj2292 changed the title fix: parameterizedSearch to return the exact match [INT-253]fix: parameterizedSearch to return the exact match Aug 4, 2023
@sanpj2292 sanpj2292 changed the title [INT-253]fix: parameterizedSearch to return the exact match fix: parameterizedSearch to return the exact match Aug 4, 2023
@rudderlabs rudderlabs deleted a comment from linear Bot Aug 4, 2023
@sanpj2292 sanpj2292 changed the title fix: parameterizedSearch to return the exact match [INT-253] fix: parameterizedSearch to return the exact match Aug 4, 2023
@sanpj2292 sanpj2292 changed the title [INT-253] fix: parameterizedSearch to return the exact match [INT-253]fix: parameterizedSearch to return the exact match Aug 4, 2023
@linear

linear Bot commented Aug 4, 2023

Copy link
Copy Markdown
INT-253 Salesforce external id issue

Reviewer: sankeerth

The internal query in the transformer code, used to get the Salesforce objects associated with the passed external id (in order to update its records) was not getting the exact object.
We were earlier getting a list of objects and considering only the first one. Now we are matching the exact object as needed, in the updated query.

quick example

{
    "searchRecords": [
        {
            "Id": "a9EAA", // we are getting this ID in transformation
            "attributes": {
                "type": "ID_TYPE__c",
                "url": "/services/data/v50.0/sobjects/ID_TYPE__c/a9EAA"
            }
        },
        {
            "Id": "a0EA2", // actual ID we should take
            "attributes": {
                "type": "ID_TYPE__c",
                "url": "/services/data/v50.0/sobjects/ID_TYPE__c/a0EA2"
            }
        }
    ]
}

Fix

We have updated the search query parameter to include the identifierType in the response

glossary

ID_TYPE__c → sobject(in Salesforce)

External_ID__c → identifierType

EXT_ID_1 → identifierValue

URL before fix

/services/data/v50.0/parameterizedSearch/\?q\=EXT_ID_1\&sobject\=id_type__c\&id_type__c.fields\=id

URL after fix

/services/data/v50.0/parameterizedSearch/\?q\=EXT_ID_1\&sobject\=id_type__c\&id_type__c.fields\=id,External_ID__c
{
    "searchRecords": [
        {
            "External_ID__c": "EXT_ID_1 TEST",
            "Id": "acEAY",
            "attributes": {
                "type": "ID_TYPE__c",
                "url": "/services/data/v50.0/sobjects/ID_TYPE__c/acEAY"
            }
        },
        {
            "External_ID__c": "EXT_ID_1",
            "Id": "abEAI",
            "attributes": {
                "type": "ID_TYPE__c",
                "url": "/services/data/v50.0/sobjects/ID_TYPE__c/abEAI"
            }
        }
    ]
}

We would match the response with the identifierValue supplied in the externalId inside event-payload & send an appropriate ID

@sanpj2292 sanpj2292 changed the title [INT-253]fix: parameterizedSearch to return the exact match fix: parameterizedSearch to return the exact match Aug 4, 2023
@yashasvibajpai
yashasvibajpai requested a review from a team as a code owner August 9, 2023 03:59
@sonarqubecloud

sonarqubecloud Bot commented Aug 9, 2023

Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

10.0% 10.0% Coverage
0.0% 0.0% Duplication

warning The version of Java (11.0.17) you have used to run this analysis is deprecated and we will stop accepting it soon. Please update to at least Java 17.
Read more here

@yashasvibajpai
yashasvibajpai merged commit 183b7b6 into develop Aug 9, 2023
@devops-github-rudderstack
devops-github-rudderstack deleted the fix.salesforce.parameterized.search branch November 10, 2023 01:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants