Skip to content

feat(pinterest_audience): add router destination on the batching framework (ACT2-1194) - #5680

Merged
arpl merged 15 commits into
developfrom
feat/act2-1194-pinterest-audience
Oct 20, 2026
Merged

arpl merged 15 commits into
developfrom
feat/act2-1194-pinterest-audience

Conversation

@arpl

@arpl arpl commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

feat(pinterest_audience): router destination on the batching framework

  • Integration: DestinationIntegration, router only, registered as PINTEREST_AUDIENCE: { routerTransform, batching }. The proxy is on by default.
  • Routing: connection config is read per row, so a single router call can hold several lists. Requests go to PATCH /v5/ad_accounts/{ad}/customer_lists/{list}, with operation_type ADD (insert/update) or REMOVE (delete) and the body format set by RECORD_FORMAT in config.ts (classic records string; records_v2 rows are kept for later, see Record format below).
  • Hashing: emails are lowercased and trimmed, and MAIDs are lowercased and checked against the UUID pattern. Phones are only normalised and sent under records_v2; the classic body drops PHONE. Then SHA-256, controlled by the connection's isHashRequired.
  • DeliverySpec:
    • Every 401 triggers a token refresh, then a retry.
    • 403, 404 (codes 1001/1018) and 400 abort, with remediation text.
    • 429 is throttled and 5xx is retried.
  • Secret paths: masks headers.Authorization. The CI check passes against integrations-config main.
  • Batch size (P1, settled): MAX_RECORDS_PER_REQUEST=1000 stays. The 2026-10-16 probe accepted ≥10,000 identifiers in one request.
  • 401: every 401 returns authExpired (REFRESH_TOKEN), so it refreshes and retries. A same-token retry can't succeed (review feedback, b6b8f3c), so no auth-body pattern is needed.
  • Not in this PR: live.ts, which follows with the CI secret.
  • Tests: unit 79/79 (--testPathPattern=pinterest_audience) and component 16/16, including mixed connections, a hashing mismatch, and both record formats.

Spec: rudder-specs #224, at lookout-audiences-initiative/activations/pinterest-audience/spec.md. Tickets: ACT2-1194 and ACT2-1195. Customer: Crate & Barrel.

Review: this went through a pre-PR review panel (security, correctness, product, ops, coherence, plus 4 adversarial checks). The verdict was Approve with follow-ups, with nothing blocking, and all fixes have been applied and re-reviewed. The record is verify/2026-10-15-review-panel.md in the spec PR.

Second panel (2026-10-19, D15 delta): Approve with follow-ups, nothing blocking. See the review comment on this PR.

Verified on mini against a real Pinterest account:

  • Web app OAuth consent works, and so does Lookout Connect through the relay (caller state).
  • The ad-account and customer-list audience pickers work, and so does /setup for an existing audience.
  • A manual sync sent all 150 rows through the transformer proxy to Pinterest.
  • Writes (2026-10-19 full pass on these heads, verify/2026-10-19-full-pass.md): a web-app create sent 150/150 adds as classic records (EMAIL + MAID), and removing 5 members sent 5/5 removes.
  • 403 · 29 was never the Trial tier. Standard access was granted on 2026-10-16 and the error stayed. Pinterest enables the multi-field records_v2 body per app, and ours isn't enabled yet (request filed). That's why v1 sends the classic format (D15).
  • Format switch, live (2026-10-19, while it was still a definition property): records_v2 was refused 0/145 with 403 · 29, and records delivered 145/145. The switch is now the transformer constant RECORD_FORMAT (review on config chore(deps): bump docker/build-push-action from 4.1.1 to 5.1.0 #2839).

Merge order (spec §10):

  1. auth-service creds + rudder-auth
  2. integrations-config (ships hidden: true)
  3. integrations-info + transformer
  4. rudder-icons mapping release (done: @rudderlabs/icons 0.6.0)
  5. web app + Lookout (icons bump)
  6. operator values
  7. Lookout RS_ACCOUNTS_OAUTH_DEFINITIONS
  8. hidden: false (Standard was granted 2026-10-16)

Record format (D15): the body is the classic records string (SHA-256 values joined by commas, one identifier per record, PHONE dropped). RECORD_FORMAT in config.ts selects it, and the records_v2 multi-field path stays for when Pinterest enables it for our app. Why: on 2026-10-16 Pinterest returned 403 code 29 for records_v2 and 200 for records on the same list for app 1624584 on Standard. An earlier revision read the format from the definition's config.recordFormat; integrations review on config #2839 moved it into code, so the shared definition schema stays Pinterest-free. A recordFormat on the definition is ignored (test D19).

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Oct 15, 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
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2456bc10-eef3-4ac4-9ccd-ef7aa21b2ead

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 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.21%. Comparing base (a4f838b) to head (d49aa96).
⚠️ Report is 7 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #5680      +/-   ##
===========================================
+ Coverage    92.16%   92.21%   +0.04%     
===========================================
  Files          719      725       +6     
  Lines        40017    40174     +157     
  Branches      9366     9321      -45     
===========================================
+ Hits         36883    37045     +162     
- Misses        2869     2945      +76     
+ Partials       265      184      -81     

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

arpl and others added 2 commits October 16, 2026 18:13
…definition asks for records_v2

Includes the component fixtures for both formats (T2+T3).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@arpl arpl closed this Oct 19, 2026
@arpl arpl reopened this Oct 19, 2026
…terest-audience

# Conflicts:
#	src/features.test.ts
#	src/features.ts
@arpl

arpl commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author

Review panel: Pinterest Audience D15 (classic records format) delta

Verdict: Approve with follow-ups. Nothing is blocking. The code does what D15 says in every repo. What's left is text: PR bodies, the spec and the flip recipe. Lookout #966 also needs a main merge.

The panel covered the delta since the 2026-10-15 panel, on these heads:

PR Head
config #2839 d439f807
transformer #5680 fb3e9cf55
info #800 2207389
webapp #10275 366cf83e4
Lookout #966 2c05d2cdc
webapp #10280 00d60d47c
specs #224 17fa950

Tally: 5 lenses (security, correctness, product, ops, coherence), 2 adversaries, both HOLDS. Codex was unavailable because the provider key is missing from its runtime.

Live verification (mini, real Pinterest, conn 3KjkihtPMxpVKN9rZfN8e5OsUId, 145 rows, full sync)

Definition config.recordFormat (served after a forced workspace-config cache rebuild) Body sent Pinterest Sync result
records classic records string 200 145/145 succeeded (run dbau6vaqj4as73c35krg)
records_v2 multi-field records_v2 403 {"code":29} 0/145, every row aborted with the actionable "Pinterest refused the request…" message (run dbau2vaqj4as73c35kq0)

This proves the wiring end to end: definition config → config-backend → rudder-server → transformer DestinationDefinition.Config.recordFormat.

Note for anyone repeating this: a direct DB edit of the definition is not served until the workspace-config cache is rebuilt. Our first records_v2 attempt went out classic for exactly that reason: Redis sits between config changes and data-plane polling. Use the APIs or force a cache rebuild.

The earlier pass is verify/2026-10-19-full-pass.md: web-app create, 150/150 adds (EMAIL+MAID), 5/5 mirror removes. It ran webapp at 2b41f8dab. The later webapp commits (MappingCell, icon alignment, master merge) are covered by unit tests and the before/after screenshots on #10275.

Findings

Should-fix

  1. The D15 flip recipe is incomplete and has no order. Survived the adversary. spec D15 (spec.md:129) and the chore(deps): bump docker/build-push-action from 4.1.1 to 5.1.0 #2839 body say "one-line config PR + info PR re-adding PHONE". The flip also has to restore:

    • PHONE in config mappingGuidance (db-config.json);
    • the webapp phone/country-code hint;
    • the phone line in Lookout's about and hashesPiiDescription.

    Order matters. Info first means PHONE shows up in the mapper while the transformer is still on classic, so a PHONE-only row aborts (D21) and phone is silently dropped from mixed rows (D20). Config first is harmless. Fix: write the checklist and order into D15 and §10.

  2. A saved PHONE mapping is silently ignored, and nothing explains it. Survived the adversary; executed.

    • info /setup accepts to: PHONE.
    • The webapp shows a raw PHONE value with no option behind it.
    • Lookout prints it verbatim.
    • The transformer drops it before processing, so nothing is counted as invalid.

    Only dev, mini and agent-written connections can hold such a mapping, since Pinterest is unreleased. Fix: one sentence in mappingGuidance, e.g. "PHONE is not supported yet; mappings to it are ignored."

  3. PR bodies are stale.

  4. Spec text contradicts D15 and chore(deps): bump docker/build-push-action from 4.1.1 to 5.1.0 #2839. None of these were in the delta:

    • D2 (:117, "email, MAID, phone");
    • D4 (:119, Trial);
    • D5 (:120, records_v2);
    • the status line "D1–D14";
    • the endpoints table (:191,193);
    • §4 (:292, ^.{1,100}$; the KSUID rule is missing);
    • the sample mappingGuidance (:277);
    • §12 acceptance (:583, "map email/MAID/phone");
    • the observability doc (429s blamed on Trial, no 403 code 29 troubleshooting row).
  5. Lookout CustomerIO Source - addl. event support #966 conflicts with main. HubSpot fetchV2 api support (#916) #919 added rows next to Pinterest's in ui/src/audiences/icons/DestinationTypeIcon.tsx and docs/data-handling.md. Keep both sides, then re-run the tests for activation-destinations and destinationTypes.

Nits

  • The transformer it.each should pin that "RECORDS_V2" and " records_v2" resolve to classic. Mutation T2 survived.
  • The config recordFormat enum has no negative test. Widening or deleting it passes every test.
  • The D20 test claims "not counted as invalid" but never spies on the stat.
  • schemaGenerator.py -update without --skip-deletions strips the KSUID allOf. The fixtures catch that. Add a $comment, and change the chore(deps): bump docker/build-push-action from 4.1.1 to 5.1.0 #2839 body from "no diff" to "no warnings".
  • spec :363 and info config.ts:32 say create "accepts either format". Evidence shows records_v2 creates also get a 403. The intended claim is that classic works before and after the flip.
  • The webapp master merge also carries a blank line in .agents/knowledge/architecture.md and a brace reformat in stepsStore.ts. Harmless.

Held up (checked)

  • Customers can't set the format. recordFormat is read only from the definition config.
    • DestinationDefinitionT{ID,Name,DisplayName,Config} has no Options, so config was the right home.
    • Absent, unknown, non-string, case-variant or padded values all resolve to classic, which fails safe.
    • No release order sends records_v2 early.
  • The classic body is correct.
    • records is the comma-joined SHA-256 values, one identifier per record.
    • Order is kept, and an email+MAID row becomes 2 records.
    • Each request holds one list and one operation.
    • Hex values can't contain commas, and no raw PII or values appear in errors or logs.
  • The KSUID rudderAccountId rule compiles under config-backend's Ajv (strictTypes).
    • "", 26-character, non-base62 and trailing-newline ids are rejected, and a 27-character KSUID is accepted.
    • It is enforced on create and update (VALIDATION_ENABLED=true in every environment).
    • The workspace-scoped account lookup is unchanged.
  • info always seeds classic, and /listFields returns EMAIL+MAID.
  • Mutations: 27 of 31 were killed by tests. The 4 survivors are the test gaps listed in the nits.
  • Tests pass in every repo:
    • transformer 91/91 + 16/16 component on the merge head;
    • info 73/73;
    • config 6,451/6,451;
    • webapp: 459 tests across 45 suites under forms/** and configurationV2;
    • Lookout 123 + 80.
  • The mapper fix applies MappingCell to all four cells. Long labels truncate and keep their native title tooltip. #10280 changes exactly 12 forms from baseline to alignItemsCenter, and no column-option Flex is left on baseline.
  • Merge resolutions keep both sides. The transformer has PINTEREST_AUDIENCE + HS_AUDIENCE; the webapp registry has Pinterest + HubSpot. Everything except CustomerIO Source - addl. event support #966 merges cleanly against its base.

Limits

  • Codex was unavailable (AZURE_FOUNDRY_KEY missing from the runtime), so there was no second-model lane.
  • records_v2 success can't be shown until Pinterest enables it for app 1624584 (request filed).
  • No live check that MAIDs in a list_type: EMAIL list actually match. Pinterest's counters only confirm receipt.

…ilent PHONE drop

- resolveRecordFormat: "RECORDS_V2", " records_v2", "records_v2 " and null stay classic,
  so a forgiving resolver (trim/lowercase) can no longer switch to records_v2 unnoticed.
- D20 now spies on stats.increment with a too-short phone, so it fails if PHONE reaches
  processAudienceRecord under the classic format instead of being dropped first.
- config.ts: P1 ran on 2026-10-16 (>= 10,000 classic identifiers accepted); the
  MAX_RECORDS_PER_REQUEST comment no longer calls it provisional.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@arpl
arpl marked this pull request as ready for review October 19, 2026 10:02
@arpl
arpl requested review from a team as code owners October 19, 2026 10:03
Review feedback: a 401 whose body did not match the auth pattern was retried with
the same token, which cannot succeed and only burned router retries. Every 401
now returns authExpired (REFRESH_TOKEN). A refresh that was not needed is
harmless, a revoked grant fails the refresh and is handled by rudder-auth, and
the provisional auth-message pattern (probe P5) is no longer needed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
shekhar-rudder
shekhar-rudder previously approved these changes Oct 19, 2026
…tant

Review on rudder-integrations-config#2839: `recordFormat` is Pinterest-specific
and should not be declared in the shared definition schema. The body format is
now `RECORD_FORMAT` in config.ts (classic `records`) instead of the definition's
`config.recordFormat`. The `records_v2` path stays; switching to it is a code
change released with the info and UI steps in spec D15.

Unit tests switch the format with `jest.replaceProperty`, and D19 now proves a
`recordFormat` on the definition is ignored. Component and delivery fixtures use
the classic body only. The records_v2 duplicate of the mixed-identifier case is
dropped, and D7 now uses an invalid email.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@am6010 am6010 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed with a small panel: one read-only reviewer that ran the tests in its own worktree, plus a challenger that tried to refute each should-fix. Reviewed at b6b8f3c21, then re-checked at d49aa9637, where the record format became a code constant.

Nits

  1. The "every 401 refreshes" behaviour has only unit tests. The thread reply says component tests were updated, but the only dataDelivery 401 case (dataDelivery/data.ts:107) still sends the auth body {code:2,"Authentication failed."}. Add one empty-body 401 case that expects REFRESH_TOKEN. The old non-auth branch would have aborted, so this is the case worth pinning.
  2. delivery.ts:56-59: the 403 message uses messageOf() where the other branches use extractPinterestErrorMessage(), so the top-level reason never shows Pinterest's code. It always says "Check the connected account still has access to ad account X". That points the wrong way for code 29, the expected refusal when the constant is switched to records_v2 before Pinterest enables it. Use extractPinterestErrorMessage, and optionally add a code-29 hint.
  3. The PR body says "unit 79/79". At b6b8f3c21 there were 78, and the count has changed again since.

Verified

  • 205/205 unit tests (including the batching framework) and 16/16 component tests pass at b6b8f3c21.
  • A 1001-row probe split into 1000 + 1, with each job output exactly once and in order.
  • Emails are trimmed and lowercased, and MAIDs are validated and lowercased.
  • PHONE is dropped before validation under classic.
  • 429 still falls back to throttled (D16), and 403/404/400/1001/1018 abort.
  • No raw PII appears in errors.
  • secretPaths masks Authorization.
  • The required connection fields match what info #800's /setup writes.

@sonarqubecloud

Copy link
Copy Markdown

@arpl
arpl merged commit 4b476f9 into develop Oct 20, 2026
51 checks passed
@arpl
arpl deleted the feat/act2-1194-pinterest-audience branch October 20, 2026 06:41
@lvrach

lvrach commented Oct 20, 2026

Copy link
Copy Markdown
Member

Post-merge review (this PR merged on 2026-10-20 at the reviewed head). None of these blocks; they are follow-ups. These are LLM findings, needs human review. Each was checked by an Opus and a Codex validator that tried to refute it.

[minor] No test/integrations/destinations/pinterest_audience/live.ts, so the green "Live Integration Tests" job runs nothing for Pinterest (the matrix generator returns {"include":[]} for this destination). Spec §7.4 says live tests from day one.

[minor] Test gaps shown by surviving mutants:

  • __tests__/routerTransform.test.ts:339: the missing-token test checks only the message. Swapping OAuthSecretError for InstrumentationError (500 to 400) passed both suites.
  • delivery.ts:36: code 1018 is tested only under the 404 override. Removing 1018 from LIST_NOT_FOUND_CODES passed both suites.

[question] delivery.ts: a 200 response whose body carries Pinterest code 2741 (NO_VALID_USER_LIST) marks every job delivered. Pinterest documents 2741 for the update call but not its HTTP status. Has a live run shown which status it comes with?

[question] With isHashRequired: false, an uppercase 64-hex value is sent unchanged (audienceUtils.ts:159-162). Pinterest documents no hex-case rule. Lowercasing pass-through values would remove the doubt.

[minor] utils.ts:21: an IDFA in the MAID column is lowercased, hashed and sent. Pinterest's help center forbids lists that contain IDFA data, and the code cannot tell an IDFA from an AAID by shape, so the web app and Lookout copy is the only guard. config.ts:58 still says classic records carry "emails, MAIDs, IDFAs".

[nit] delivery.ts:62: every 404 says "Customer list N was not found", also for an ad-account 404 or an empty body. Customers still see Pinterest's raw body per job; the wrong hint reaches the top-level message and logs.

[nit] An MD5 or SHA-1 pre-hashed email fails with "appears to be unhashed". Pinterest accepts those hashes and the spec rejects them on purpose, but the message sends the user to turn hashing on. "must be SHA-256 hex" would be clearer.

[fyi] ADD and REMOVE for one identifier in one router batch follow group order, not job order (shared batching framework). A normal mirror sync finishes its adds before its removes, so this is not reachable today.

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.

4 participants