Repository navigation
fix(salesforce): escape the email in the Lead SOQL lookup - #5604
Conversation
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
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
|
…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]>



What are the changes introduced in this PR?
The Salesforce V2 Lead lookup now escapes the email with
soqlEscapeValuebefore it builds the SOQL query. The record lookup beside it already does this. The record lookup also checksobjectTypeagainstSOQL_FIELD_NAME_REGEX, the same checkidentifierTypealready has.What is the related Linear task?
Resolves INT-6868
Please explain the objectives of your changes below
getSalesforceIdForLeadUsingSdkput the email into the query string as it was. An email that contains a single quote, such aso'[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, becauseEmailis 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
soqlEscapeValueandSOQL_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.jspasses 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 invalidobjectType. 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