Skip to content

fix(intercom): keep mapped external_id in rETL v2 flow when email is absent - #5730

Merged
krishna2020 merged 1 commit into
developfrom
feature/int-7442-intercom-retl-v2-mapped-external_id-overwritten-when-email
Oct 27, 2026
Merged

krishna2020 merged 1 commit into
developfrom
feature/int-7442-intercom-retl-v2-mapped-external_id-overwritten-when-email

Conversation

@krishna2020

@krishna2020 krishna2020 commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

What are the changes introduced in this PR?

Fixes the Intercom (API v2) rETL identify flow dropping an explicitly mapped external_id when email is absent.

In rEtlPayload, external_id was set to traits.user_id whenever email was missing. When the identifier is mapped as external_id (context.externalId[0].identifierType: external_id, so there is no user_id trait), this overwrote the valid external_id with undefined. searchContact had already looked the contact up by that external_id, but the event then failed with Either email or userId is required for Identify call.

The fix keeps the mapped external_id and falls back to user_id only when it is missing:

payload.external_id = $.outputs.apiVersion === "v2" && !payload.email ? (payload.external_id || payload.user_id) : null;

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_id alone.

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

Only for API v2 + rETL (context.mappedToDestination), no email, with traits.external_id set: the payload now carries that external_id, which is the same value searchContact used for lookup. Before, these events failed, or sent user_id while the lookup used external_id.

Unchanged: records with an email (external_id is still not sent), API v1, the identifierType: user_id flow, and event stream.

Blast radius from control-plane config: 22 enabled v2 rETL Intercom destinations; 18 of them use the identifierType: user_id constant, and only records with no email where traits.external_id ends 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:

  • test-20: v2 rETL, external_id mapped, no email, contact not found → POST with external_id
  • test-21: same, contact found → PUT with external_id
  • test-22: external_id + email → behaviour unchanged (external_id not 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

…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]>
@krishna2020
krishna2020 requested review from a team as code owners October 26, 2026 14:27
Copilot AI balanced review requested due to automatic review settings October 26, 2026 14:27
@coderabbitai

coderabbitai Bot commented Oct 26, 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
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8b0fa002-7225-4712-a854-ea5945f8e093

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
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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 to user_id when 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

@sonarqubecloud

Copy link
Copy Markdown

@codecov

codecov Bot commented Oct 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.39%. Comparing base (ca0dbb9) to head (7eadfee).

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.
📢 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.

@ItsSudip ItsSudip left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@krishna2020
krishna2020 merged commit 5e56bbe into develop Oct 27, 2026
51 of 53 checks passed
@krishna2020
krishna2020 deleted the feature/int-7442-intercom-retl-v2-mapped-external_id-overwritten-when-email branch October 27, 2026 05:26
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.

3 participants