Skip to content

fix(salesforce): escape the email in the Lead SOQL lookup - #5604

Merged
lvrach merged 1 commit into
developfrom
fix/int-6868-salesforce-escape-lead-email
Sep 23, 2026
Merged

lvrach merged 1 commit into
developfrom
fix/int-6868-salesforce-escape-lead-email

Conversation

@lvrach

@lvrach lvrach commented Sep 23, 2026

Copy link
Copy Markdown
Member

What are the changes introduced in this PR?

The Salesforce V2 Lead lookup now escapes the email with soqlEscapeValue before it builds the SOQL query. The record lookup beside it already does this. The record lookup also checks objectType against SOQL_FIELD_NAME_REGEX, the same check identifierType already has.

What is the related Linear task?

Resolves INT-6868

Please explain the objectives of your changes below

getSalesforceIdForLeadUsingSdk put the email into the query string as it was. An email that contains a single quote, such as o'[email protected], produced malformed SOQL, and the event failed. With escaping, that email matches its Lead like any other.

String(email) keeps a numeric value quoted, as before, because Email is a text field.

Internal write-up, including how this was found and the customer impact (RudderStack sign-in required): https://rudder-office.fly.dev/docs/int-6868-salesforce-lead-lookup.html

Any changes to existing capabilities/behaviour, mention the reason & what are the changes ?

Emails with a single quote or a backslash now match their Lead instead of failing. Every other email produces the same query as before.

Any new dependencies introduced with this change?

N/A

Any new generic utility introduced or modified. Please explain the changes.

N/A. The change reuses the existing soqlEscapeValue and SOQL_FIELD_NAME_REGEX.

Any technical or performance related pointers to consider with the change?

Only Salesforce V2 uses this query path, and only for workspaces not listed in DEST_SALESFORCE_SOQL_SKIP_WORKSPACE_IDS. The legacy destination and the sandbox variant use the URL-encoded search and do not change.

How to verify

npx jest src/v0/destinations/salesforce/utils.test.js passes 70 of 70. Five new cases assert the exact SOQL string for four emails (a single quote, a backslash with a quote, o'[email protected], and a numeric value) and reject an invalid objectType. On the code before this change, four of them fail; the numeric case passes by design.

What is not covered

  • utils.js:295: the HTTP record search puts its values into the query string without URL encoding. It is a separate path and a separate change.
  • utils.js:183: the legacy token URL builds its query string from destination config values.

Developer checklist

  • My code follows the style guidelines of this project

  • No breaking changes are being introduced.

  • All related docs linked with the PR?

  • All changes manually tested?

  • Any documentation changes needed with this change?

  • Is the PR limited to 10 file changes?

  • Is the PR limited to one linear task?

  • Are relevant unit and component test-cases added in new readability format? Unit cases in utils.test.js.

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.

🤖 Generated with Claude Code

getSalesforceIdForLeadUsingSdk put the email into the SOQL string
without escaping. An email with a single quote, such as
o'[email protected], produced malformed SOQL and the event failed.
The query now uses soqlEscapeValue, like the record lookup does.
String(email) keeps a numeric value quoted, as before.

getSalesforceIdForRecordUsingSdk now also checks objectType against
SOQL_FIELD_NAME_REGEX, the same check identifierType already has.

Verify: jest -c jest.default.config.js src/v0/destinations/salesforce
The new cases fail on develop and pass with this change.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

🔒 Scanned for secrets using gitleaks 8.30.1
@lvrach
lvrach requested review from a team as code owners September 23, 2026 07:19
@coderabbitai

coderabbitai Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: b69cd4ad-6fe4-4dc7-9be9-ce366a3c28be

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Sep 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.01%. Comparing base (dfdd95f) to head (6fe14cc).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #5604   +/-   ##
========================================
  Coverage    93.01%   93.01%           
========================================
  Files          729      729           
  Lines        39437    39439    +2     
  Branches      9198     9199    +1     
========================================
+ Hits         36682    36684    +2     
  Misses        2556     2556           
  Partials       199      199           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sonarqubecloud

Copy link
Copy Markdown

@lvrach
lvrach merged commit 9a78786 into develop Sep 23, 2026
37 checks passed
@lvrach
lvrach deleted the fix/int-6868-salesforce-escape-lead-email branch September 23, 2026 14:17
shekhar-rudder added a commit that referenced this pull request Sep 24, 2026
…asured

Merging develop showed two things the branch could not see from its own base.

EVERFLOW landed on develop after the branch was cut, so CI derived 200
destinations against a manifest holding 199. It derives
`params.verification_token` from its declared `secretKeys` - the configured
source, unrelated to this change.

SALESFORCE derived `null` rather than `["headers.Authorization"]`, which the
branch's own base could not reproduce because develop carries two Salesforce
transform fixes (#5603, #5604) that change how it responds to a decoy. With the
bag measured first, SALESFORCE turns out to destabilise under it: the bag moves
`endpoint` and `headers.Authorization` on the cases that hold, and a later case
collapses the transform entirely, which discarded every measured location and
masked the destination wholesale.

So the rescue is now skipped only when the bag destabilised *and* was never
compared cleanly in any case. That is the case the guard was added for - a
rescue result says nothing about where the bag's token went, so publishing it
would be a positive claim built on unrelated evidence. When the bag was compared
cleanly somewhere, its locations came from the same corroborated diff every
other path comes from, and discarding them to punish an unrelated case trades a
measured answer for a blunter one.

200 destinations: 118 with derived paths, 82 with nothing to mask, 0 fail-closed.

Fixture-quality gaps that bound this - dual-use credential values, paths resting
on a single case, a declared credential no fixture populates - are tracked
separately in INT-7221, which is fixture-only.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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.

2 participants