Skip to content

fix(openai_ads): honor destination hashing configuration - #5718

Merged
ItsSudip merged 5 commits into
developfrom
harness/INT-7432-fix-openai-ads-honor-destinatio-1447d4b7
Oct 26, 2026
Merged

ItsSudip merged 5 commits into
developfrom
harness/INT-7432-fix-openai-ads-honor-destinatio-1447d4b7

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?

OpenAI Ads cloud transformations now honor destination-level isHashRequired. Hashing remains enabled when the setting is absent, while disabling it accepts valid pre-hashed customer identifiers and lowercases them before delivery.

When hashing is disabled and userId is absent, the SDK-generated anonymousId fallback is handled separately: an existing SHA-256 digest passes through lowercased, while a plain value is normalized and hashed through the existing external-ID path. Audience hashing consistency metrics also carry the real workspace and destination identifiers.

The transformer passes only plain destination metadata through the OpenAI Ads builder. The descriptor required by processAudienceRecord is constructed at the utility call boundary, and hash-format recognition is shared with audience consistency validation.

Focused unit and component coverage verifies enabled, disabled, and default behavior, all supported hashed identifiers, anonymous-ID fallback handling, mixed/plain input rejection, metric attribution, and the shared hash-format predicate.

What is the related Linear task?

Resolves INT-7432

Please explain the objectives of your changes below

Allow customers that hash OpenAI Ads identifiers upstream to disable transformer hashing without changing the existing default behavior. The matching destination configuration is provided by rudder-integrations-config#2864.

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

When isHashRequired is false, email, phone number, first name, last name, and userId must already be normalized and SHA-256 hashed; plain values remain rejected. Pre-hashed values are emitted as lowercase hexadecimal strings. If userId is absent, RudderStack automatically normalizes and hashes a plain anonymousId fallback, or lowercases and passes through an already-hashed fallback. An absent or true setting retains the existing normalization and hashing behavior.

Any new dependencies introduced with this change?

N/A

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

Exposes isAlreadyHashed(value, hashingType) from the shared audience utility and uses it in both hashing-consistency validation and the OpenAI Ads anonymous-ID fallback decision. The shared digest regex remains the single definition of an already-hashed value.

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

OpenAI Ads passes workspaceId and destinationId as plain metadata through its builder. processHashedUserPayload constructs the destination descriptor only where processAudienceRecord is called, preserving the uppercase OPENAI_ADS metric series without leaking the audience utility input shape through the transformer.

Validation

  • npm run lint - passed
  • npm test -- --testPathPattern="src/v0/(destinations/openai_ads/routerTransform|util/audienceUtils).test.ts" --no-coverage --runInBand - passed, 120 tests
  • npm run test:ts -- component --destination=openai_ads - passed, 14 tests
  • ./node_modules/.bin/tsc --noEmit -p tsconfig.test.json - passed
  • Full secret-path regeneration passed; OpenAI Ads still derives only headers.Authorization, and the aggregate artifact remains unchanged
  • git diff --check - passed
  • Simplification pass reused the existing plaintext and SHA-256 fixtures across the new helper cases and consistency tests

⚠️ Known Issues

  • End-to-end runtime verification was skipped because the local stack uses a SHA-pinned transformer image and cannot source-exercise this change.
  • Web device-mode support for isHashRequired will follow in rudder-sdk-js#3295.
  • Release remains dependent on the matching integrations-config rollout and required rudder-hugo documentation covering pre-hashed customer identifiers, automatic anonymous-ID fallback hashing, normalization responsibilities, and both cloud and web device-mode behavior.

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? Required rudder-hugo dependency described above.
  • 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: 78a86f83-60bc-4473-85e4-bb5ee6d45219

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.

@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.35%. Comparing base (f1dd798) to head (d237125).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #5718      +/-   ##
===========================================
+ Coverage    92.33%   92.35%   +0.02%     
===========================================
  Files          737      737              
  Lines        40850    40848       -2     
  Branches      9507     9505       -2     
===========================================
+ Hits         37719    37726       +7     
+ Misses        2947     2938       -9     
  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

Copy link
Copy Markdown
Member

@rudder-devbox please address the following review feedback on this PR:

  1. Lowercase pre-hashed values on pass-through
    When isHashRequired is false, pre-hashed values are passed through unchanged. The shared consistency check accepts upper- and lowercase hex (/^[\dA-Fa-f]{64}$/), but OpenAI requires each *_sha256 value to be "a lowercase, 64-character hexadecimal string", and a batch is all-or-nothing — one uppercase digest can fail the whole batch. Lowercase every pass-through value for emails_sha256, phone_numbers_sha256, external_ids_sha256, first_names_sha256, and last_names_sha256 before it is added to the payload. Add a test with uppercase hex input asserting lowercase output.

  2. Cover the anonymousId fallback with hashing disabled
    external_ids_sha256 is sourced from userId, falling back to anonymousId. With hashing disabled, customers are expected to pre-hash anonymousId too (e.g. via a user transformation) when userId is absent. Add tests for an event with only anonymousId and isHashRequired: false:

    • pre-hashed anonymousId → passed through as external_ids_sha256
    • plain anonymousId → rejected with the "appears to be unhashed" error
  3. PR description

    • Link the matching config PR: feat(openai-ads): add hashing configuration toggle rudder-integrations-config#2864
    • Under Known Issues, replace "cloud-only scope" — web device mode support for isHashRequired will follow in rudder-sdk-js.
    • In the behaviour section, state explicitly that with hashing disabled all five identifiers must be pre-hashed, including anonymousId when it is used as the external ID fallback.

@ItsSudip

Copy link
Copy Markdown
Member

@rudder-devbox follow-up that supersedes item 2 of my previous comment (the anonymousId handling). Items 1 and 3 still apply.

Auto-hash the anonymousId fallback when hashing is disabled
external_ids_sha256 is sourced from userId, falling back to anonymousId. anonymousId is generated by the RudderStack SDK, not supplied by the customer, so customers can't be expected to pre-hash it. When isHashRequired is false and the external ID comes from anonymousId (no userId on the event):

  • if the value already matches a 64-char hex SHA-256 → pass it through, lowercased (same as item 1);
  • otherwise → normalize and SHA-256 hash it using the same external-ID normalization/hash path used when hashing is enabled (don't introduce a new normalization variant here — external-ID normalization alignment with OpenAI's spec is tracked separately).

userId, email, phone, first name, and last name keep the pre-hashed rule: when hashing is disabled they must already be hashed, and plain values are still rejected. Note constructPayload doesn't tell you which source key matched — determine the anonymousId case from the message (no userId, anonymousId present).

Tests (replacing the ones requested in item 2), all with isHashRequired: false:

  • only anonymousId, plain UUID → external_ids_sha256 is the SHA-256 of the normalized anonymousId
  • only anonymousId, uppercase pre-hashed hex → passed through lowercased
  • userId plain (with or without anonymousId) → still rejected with the "appears to be unhashed" error

PR description: document that with hashing disabled, email, phone, first/last name, and userId must be pre-hashed, while an anonymousId fallback is hashed by RudderStack automatically.

@rudder-devbox

rudder-devbox Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

Implemented the superseding anonymous-ID behavior. With hashing disabled, a fallback anonymousId now passes through lowercased when already hashed, or uses the existing external-ID normalization/SHA-256 path when plain. A present plain userId is still rejected with or without anonymousId, and all pre-hashed pass-through fields remain lowercased.

Added the three requested focused cases and updated the PR description with the config PR link and the corrected identifier contract. Validation passed: lint, 88 unit tests, 14 component tests, TypeScript, full secret-path regeneration, and git diff --check.

Pushed in 7e9fdc112af138e659b4bf1344a5f7ade448d936.

@rudder-devbox

rudder-devbox Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

Knowledge distillation completed

Comment thread src/v0/destinations/openai_ads/utils.ts Resolved
@rudder-devbox

rudder-devbox Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

Knowledge distillation completed

@rudder-devbox
rudder-devbox Bot requested a review from ItsSudip October 23, 2026 11:09
@rudder-devbox

rudder-devbox Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

Knowledge distillation completed

@sonarqubecloud

Copy link
Copy Markdown

@ItsSudip
ItsSudip marked this pull request as ready for review October 23, 2026 12:48
@ItsSudip
ItsSudip requested review from a team as code owners October 23, 2026 12:48
@ItsSudip
ItsSudip requested a review from krishna2020 October 23, 2026 12:48
@ItsSudip
ItsSudip merged commit a69ac12 into develop Oct 26, 2026
52 of 53 checks passed
@ItsSudip
ItsSudip deleted the harness/INT-7432-fix-openai-ads-honor-destinatio-1447d4b7 branch October 26, 2026 03:53
};

const hashUserPayload = (
const processHashedUserPayload = (

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
const processHashedUserPayload = (
const processUserPayload = (

HashedUserPayload is confusing as it implies input is already hashed @ItsSudip

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