Repository navigation
fix(intercom): keep mapped external_id in rETL v2 flow when email is absent - #5730
Conversation
…absent In the rETL identify flow for API v2, rEtlPayload set external_id to traits.user_id whenever email was absent, overwriting an explicitly mapped traits.external_id. When the identifier is mapped as external_id (no user_id trait), the payload lost it and the event failed with "Either email or userId is required for Identify call", even though searchContact had already looked the contact up by that external_id. Keep the mapped external_id and fall back to user_id only when it is missing. Behaviour with email present, v1, and event stream is unchanged. Resolves INT-7442 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
There was a problem hiding this comment.
🟢 Approval recommended
The fix is narrowly scoped, preserves existing fallback behavior, and includes regression coverage for the affected paths.
No open issues 🎉
What changed in this PR
Fixes the Intercom API v2 rETL identify flow so records without email retain an explicitly mapped external_id, keeping the outgoing payload consistent with contact lookup.
Changes:
- Preserves mapped
external_id, falling back touser_idwhen absent. - Adds regression cases for contact creation, contact updates, and unchanged email-present behavior.
| File | Description |
|---|---|
test/integrations/destinations/intercom/processor/identifyTestData.ts |
Adds shared fixtures and three regression cases. |
src/cdk/v2/destinations/intercom/procWorkflow.yaml |
Preserves mapped external_id in the v2 rETL payload when email is absent. |
Review effort: Balanced
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #5730 +/- ##
========================================
Coverage 92.39% 92.39%
========================================
Files 737 737
Lines 40853 40853
Branches 9508 9507 -1
========================================
Hits 37748 37748
Misses 2921 2921
Partials 184 184 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
ItsSudip
left a comment
There was a problem hiding this comment.
LGTM. Verified locally on develop with the failing payload shape: the as-delivered event (identifierType: external_id, email: null, no traits.user_id) reproduces Either email or userId is required for Identify call, and the change keeps the mapped external_id so the identify goes through.



What are the changes introduced in this PR?
Fixes the Intercom (API v2) rETL identify flow dropping an explicitly mapped
external_idwhen email is absent.In
rEtlPayload,external_idwas set totraits.user_idwhenever email was missing. When the identifier is mapped asexternal_id(context.externalId[0].identifierType: external_id, so there is nouser_idtrait), this overwrote the validexternal_idwithundefined.searchContacthad already looked the contact up by thatexternal_id, but the event then failed withEither email or userId is required for Identify call.The fix keeps the mapped
external_idand falls back touser_idonly when it is missing:What is the related Linear task?
Resolves INT-7442
Please explain the objectives of your changes below
An Intercom rETL sync on v2 can't create contacts that have no email, even though Intercom accepts
external_idalone.Any changes to existing capabilities/behaviour, mention the reason & what are the changes ?
Only for API v2 + rETL (
context.mappedToDestination), no email, withtraits.external_idset: the payload now carries thatexternal_id, which is the same valuesearchContactused for lookup. Before, these events failed, or sentuser_idwhile the lookup usedexternal_id.Unchanged: records with an email (
external_idis still not sent), API v1, theidentifierType: user_idflow, and event stream.Blast radius from control-plane config: 22 enabled v2 rETL Intercom destinations; 18 of them use the
identifierType: user_idconstant, and only records with no email wheretraits.external_idends up set (e.g. via a user transformation) change behaviour.Any new dependencies introduced with this change?
N/A
Any new generic utility introduced or modified. Please explain the changes.
N/A
Any technical or performance related pointers to consider with the change?
N/A
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?
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.
Testing
New processor component tests (
identifyTestData.ts), modelled on the anonymised failing payload:external_idmapped, no email, contact not found → POST withexternal_idexternal_idexternal_id+ email → behaviour unchanged (external_idnot sent)Without the fix, tests 20 and 21 fail with
Either email or userId is required for Identify call. With it, all 73 Intercom component tests and 54 Intercom unit tests pass.🤖 Generated with Claude Code