Skip to content

feat(custom_audience): support OAuth linked accounts - #5717

Merged
achettyiitr merged 27 commits into
developfrom
harness/INT-7425-feat-custom-audience-support-oa-d52d7d7e
Nov 7, 2026
Merged

achettyiitr merged 27 commits into
developfrom
harness/INT-7425-feat-custom-audience-support-oa-d52d7d7e

Conversation

@rudder-devbox

@rudder-devbox rudder-devbox Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

What are the changes introduced in this PR?

Adds OAuth Client Credentials and Authorization Code linked-account authentication for Custom Audience. Bearer credentials are sourced from each event's metadata.secret.accessToken, and per-event header resolution prevents events with different tokens from sharing a batch.

What is the related Linear task?

Resolves INT-7425

Please explain the objectives of your changes below

Support the two Custom Activation OAuth account definitions while preserving linked-account precedence and explicit no-auth behavior.

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

OAuth-linked Custom Audience events now authenticate with the event metadata access token. Existing non-OAuth linked-account authentication behavior remains unchanged. A missing OAuth token raises the standard platform-classified OAuthSecretError.

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?

Headers are resolved per event because OAuth tokens are event-specific. Endpoint caching remains in place. Since headers participate in the batching composite key, events with different tokens are separated automatically, while events with the same token remain batched.

Known limitation

OAuth previews fail closed because preview events do not include metadata.secret.accessToken. They return the missing-token OAuth error instead of using delivery-account or destination-config credentials.

Validation

  • npm run lint - passed
  • npm run build:ci - passed
  • npm test -- --testPathPattern="custom_audience" --no-coverage --runInBand - passed, 188 tests
  • npm run test:ts -- component --destination=custom_audience - passed, 14 tests
  • git diff --check - passed
  • Simplify pass - no behavior-preserving simplifications worth making

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.

@rudder-devbox

rudder-devbox Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

👋 I'm rudder-devbox. I opened this PR from a Linear ticket.

Mention @devbox or @rudder-devbox and I'll act on it — on a top-level PR comment,
in a review summary, or on an inline comment on the diff. Without a mention I won't see it.

@coderabbitai

coderabbitai Bot commented Oct 22, 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: 9f215c07-8223-4aae-bf39-e558fa202a4f

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

Tip

🎯 Customize your risk assessments

Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using Merge Risk Instructions and Security Risk Instructions in your review settings. Security architecture risk assessments require the Advanced plan or above.

✅ Automatic approvals, with your rules

Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable Automatic approvals in review settings, with overrides for teams or file paths.

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

@codecov

codecov Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.45%. Comparing base (6a245da) to head (c89a37f).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #5717   +/-   ##
========================================
  Coverage    92.44%   92.45%           
========================================
  Files          741      741           
  Lines        41121    41146   +25     
  Branches      9670     9679    +9     
========================================
+ Hits         38015    38040   +25     
  Misses        2845     2845           
  Partials       261      261           

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

@rudder-devbox

rudder-devbox Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

The HubSpot live test hs-retl-contacts-update-v1-service-key failed when HubSpot returned 409, “Contact already exists,” during the update scenario. The same commit passed when I reran the failed live (hs) job (attempt 2), confirming a transient live API/search consistency failure. CI is green; no code change was needed.

@rudder-devbox

rudder-devbox Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

Both HubSpot merged-record live scenarios failed because the test required job 0 to fail, but CI reported expectedToFailButDelivered: [0]: HubSpot accepted the merged-away contact ID. I updated the test to accept that outcome only when a read-back confirms the surviving contact was updated; omitted-result failures remain required to fail. The focused runner tests (19), HubSpot component tests (86), and TypeScript builds pass. Pushed commit 9d317f616.

@rudder-devbox

rudder-devbox Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

Knowledge distillation completed

@achettyiitr
achettyiitr requested review from a team as code owners November 5, 2026 14:03
Copilot AI balanced review requested due to automatic review settings November 5, 2026 14:03

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.

🟡 Changes recommended

Custom Audience previews can fail when the optional send flag is omitted, and events without a linked account can incorrectly enter the OAuth refresh/retry path.

2 open issues
What changed in this PR

Adds linked-account OAuth support to Custom Audience, using per-event access tokens while preserving token-aware batching.

Changes:

  • Supports Client Credentials and Authorization Code accounts with metadata-sourced Bearer headers.
  • Adds masked preview headers and refresh responses for missing machine-OAuth tokens.
  • Adds authentication, batching, preview, and controller test coverage.
File Description
test/​integrations/​destinations/​custom_audience/​router/​data.ts Adds an OAuth delivery fixture.
test/​integrations/​destinations/​custom_audience/​maskedSecrets.ts Adds a masked OAuth token fixture.
test/​integrations/​destinations/​custom_audience/​common.ts Defines a linked OAuth destination fixture.
src/​v0/​destinations/​custom_audience/​utils.ts Resolves OAuth tokens and masked preview headers.
src/​v0/​destinations/​custom_audience/​utils.test.ts Tests OAuth precedence, missing tokens, and previews.
src/​v0/​destinations/​custom_audience/​types.ts Adds authentication metadata types.
src/​v0/​destinations/​custom_audience/​routerTransform.ts Resolves headers separately for each event.
src/​v0/​destinations/​custom_audience/​routerTransform.test.ts Tests batching separation by access token.
src/​v0/​destinations/​custom_audience/​constants.ts Adds OAuth account definition names.
src/​services/​eventTest/​eventTester.ts Passes preview status into router metadata.
src/​services/​eventTest/​__tests__/​eventTester.test.ts Tests preview and send metadata behavior.
src/​controllers/​destination.ts Returns refresh responses for tokenless machine-OAuth events.
src/​controllers/​__tests__/​destination.test.ts Tests refresh interception and bypass conditions.

Review effort: Balanced

Comment thread src/controllers/destination.ts Resolved
Comment thread src/services/eventTest/eventTester.ts Resolved
Copilot AI balanced review requested due to automatic review settings November 5, 2026 14:08

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.

🟡 Changes recommended

OAuth-linked Custom Audience previews can return OAuthSecretError instead of masked payloads because omitted delivery flags and legacy endpoint calls incorrectly leave preview mode disabled.

3 open issues

Review effort: Balanced

Comment thread src/services/eventTest/eventTester.ts Resolved
@rudder-devbox

rudder-devbox Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Both arm64 image jobs failed at “Install TruffleHog”: sha256sum reported that the downloaded archive did not match its pinned digest. The digest matches TruffleHog’s published checksum, while the release URL returned HTTP 504 and a 92-byte HTML response, so this was an upstream download failure. I reran the failed jobs on the same commit; the workflow passed on attempt 2. No code change was needed.

Copilot AI balanced review requested due to automatic review settings November 6, 2026 04:44

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.

🔵 Needs a closer look

The refresh guard intercepts events without a selected linked account or with dynamically disabled authentication, replacing valid transformations or configuration errors with inappropriate retryable refresh responses.

2 open issues
2 previously missed issues

In code that hasn't changed since last review

Medium severity Resolve dynamic authentication config before the refresh guard

src/​controllers/​destination.ts:119

The refresh guard runs before dynamic configuration is resolved, so a tokenless machine-OAuth event whose authenticationEnabled template resolves to false receives REFRESH_TOKEN instead of transforming without authentication. Partition events after DynamicConfigParser.process, preserving preprocessing error handling and ensuring each event appears only once in the output. Add a regression case for a dynamically disabled authentication toggle.

Medium severity Test mixed tokenless and token-bearing machine-OAuth events

src/​controllers/​destination.ts:170

Please add a mixed-request test containing a tokenless machine-OAuth event and one with a valid access token. The new controller tests only intercept a single tokenless event or dispatch events after disabling auth/changing the authentication type; none exercises token-bearing machine OAuth or combining refresh responses with transformed responses. Assert that only the tokenless event requests refresh, the token-bearing event reaches transformation, and each event's metadata appears exactly once in the combined output.

1 resolved since last review

Review effort: Balanced

achettyiitr
achettyiitr previously approved these changes Nov 6, 2026
Copilot AI balanced review requested due to automatic review settings November 6, 2026 11:41

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.

🟡 Changes recommended

The controller’s token gate bypasses linked-account selection and validation, causing unnecessary 500/REFRESH_TOKEN retries instead of the intended no-auth or permanent configuration-error outcomes.

1 open issue
2 resolved since last review

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 7, 2026 00:14

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.

🟡 Changes recommended

The OAuth preflight can incorrectly trigger token refreshes because it runs before dynamic authentication settings are resolved and does not verify that a delivery account is selected.

1 open issue
1 resolved since last review

Review effort: Balanced

Comment thread src/controllers/destination.ts Resolved
@sonarqubecloud

sonarqubecloud Bot commented Nov 7, 2026

Copy link
Copy Markdown

@achettyiitr
achettyiitr merged commit ae7ccd0 into develop Nov 7, 2026
54 checks passed
@achettyiitr
achettyiitr deleted the harness/INT-7425-feat-custom-audience-support-oa-d52d7d7e branch November 7, 2026 00:50
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