Repository navigation
feat(gainsight_px_audience): sync trait attributes for audience members - #5703
Conversation
Members get { flag: true, ...traits } with each value converted to its PX type; leavers get
{ flag: false } only. Unconvertible values are left out and logged once per call per
(attribute, reason) with a count (trait-mappings D18, D23, D25).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…dontBatch rows Document that the left-out counter is per transformEvents pass and that dontBatch rows log separately; add a test covering it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ave on 404 With traits a member write carries several attributes, so the 404 override now keys on exactly one key whose value is false (trait-mappings D24). Adds trait dataDelivery fixtures and two live scenarios (three trait types; an unconvertible trait left out). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A stored type: null, more than 50 fieldMappings rows or a non-object fields value failed input-schema validation for the whole row, flag included (trait-mappings D18). Make the trait inputs lenient: invalid rows are dropped, rows beyond the first 50 are ignored, and a non-object fields value is treated as no field values. A row with a missing or null type still reaches collectTraits and is logged as unknown_type. Also correct the delivery 404 comment. 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 ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
… honour Co-Authored-By: Claude Opus 5.5 <[email protected]>
am6010
left a comment
There was a problem hiding this comment.
rudder-transformer#5703 review: gainsight_px_audience trait mappings
Reviewed at ed2359442 (draft, base develop); the later 02bb5f2e7 only touches a time-zone guard in traits.test.ts and doesn't change the findings (it makes S2 more relevant). Spec: rudder-specs#229 @ 6bfafd1 trait-mappings.md.
Verdict
COMMENT. I found no confirmed blocker. v1 behaviour is unchanged, leavers write only the flag, and all 135 tests pass locally. The headline claim "a bad value never blocks the flag" holds for values the transformer rejects. It does not hold for values the transformer accepts but PX may reject (S1, S3). Two of those are cheap to guard (S1, S2). Re-check S1 after the NUMBER/DATE_TIME sandbox run. If PX rejects a fractional or out-of-range DATE_TIME, S1 becomes blocking.
BLOCKING
None confirmed.
SHOULD-FIX
S1. traits.ts:58: DATE_TIME numbers are sent unchecked.
- Defect: any finite number goes out as-is. Fractional, out-of-range and epoch-seconds values are all sent.
- Verified with a probe (convertTraitValue):
1760000000000.5→ sent1760000000000.51e20→ sent1e20(not a valid JS Date)-1→ sent1760000000(epoch seconds) → sent, which PX reads as 1970-01-21
- Scenario: a Postgres model with
extract(epoch from ts)*1000gives fractional ms. If PX wants a long, it returns 400 (unverified, since the spec §3 table says DATE_TIME was not probed). PX rejects the whole write (spec §3), and delivery aborts on 400 (delivery.ts:4, dataDelivery fixture 12). So that member's flag never lands, and the row is not retried. - Fix: for a number, require
Number.isInteger(v) && Math.abs(v) <= 8.64e15, otherwise leave it out (orMath.truncfirst). Add three rows totraits.test.ts:49-58.
S2. traits.ts:29: the Date.parse fallback takes non-ISO strings and junk, and their meaning depends on the host time zone.
- Defect: only ISO zone-less strings are pinned to UTC. Every other string goes to V8's lenient
Date.parse. - Verified with
TZ=America/Los_Angeles:"10/20/2026"→2026-10-20T07:00Z"Oct 20 2026 10:00"→17:00Z"1"→2001-01-01T08:00Z"12"→2001-12-01
- Scenario: a VARCHAR column holding
"1","12"or US-format dates writes a wrong date silently. The value is not left out and nothing is logged. - Fix: accept only ISO-8601 shapes, using one regex:
YYYY-MM-DD, optional[ T]hh:mm[:ss[.f]], optionalZor±hh[:mm]. Pin zone-less values to UTC and leave everything else out. This also replacesZONELESS_DATE_TIME(traits.ts:23).
S3. PR body and spec §2: the claim is broader than the code.
- Defect: some rejections happen on the PX side, where the transformer cannot see them. Each one still blocks the flag for every member write that carries the trait:
- the attribute is disabled, deleted or retyped after
/setup(spec §6 admits this) - PX limits nobody has probed: STRING max length (a 100 000-char string is sent as-is, verified), NUMBER range or float, negative DATE_TIME
- the attribute is disabled, deleted or retyped after
- Scenario: a PX admin disables
CDP_userRole. From then on, every insert/update returns 400 → abort, so new members never gettrue. The only signal is the failed-row reason. - Fix (minimal): reword the claim to "a value the transformer cannot convert never blocks the flag". Add STRING length, NUMBER float/large and DATE_TIME bounds to the sandbox run that is already in progress. Add a guard only where PX actually rejects.
NITS
- N0
traits.ts:92. The 50-row cap runs before the shape filter, and dropped rows are never logged. Only an API-written config that bypasses/setupcan hit it.- Defect:
slice(0, 50)runs before.filter(...). Rows 51+ and malformed rows vanish without a warn, despite the "never silently disappearing" doc attraits.ts:86-87. - Verified: 10 malformed rows plus 50 valid rows keeps only 40 valid rows.
- Fix: delete the cap (
MAX_TRAIT_MAPPINGS,config.ts:36-37,traits.ts:9,92, and the test atrouterTransform.test.ts:481)./setupalready enforces 50. Sending more traits does not put the flag at risk, so the cap only loses data.
- Defect:
- N1
traits.ts:46.Number()accepts"0x1F"→31,"0b101"→5 and"1e3"→1000. It silently rounds"9007199254740993"→…992. All verified. Optional fix: a decimal regex beforeNumber(). - N2
routerTransform.ts:104,117,types.ts:64. "Flag first" is not guaranteed. JS orders integer-like keys first, and\wallows"123", so the result is{"123":"v","flag":true}(verified). This is harmless becauseisLeavecounts keys. Drop the "flag first" wording and the test name atrouterTransform.test.ts:293. - N3
traits.ts:118-123. With a duplicateto, the first value is written but the second row is logged as left out (verified). This only happens with API-saved configs, since/setuprefuses duplicates. Ignore it, or dedupe byto. - N4
traits.ts:100. Thetypenormalisation is redundant:convertTraitValuealready rejects non-string types (traits.ts:64-65,72). Passrow.typethrough. - N5
config.ts:33-34.LOG_DEST_TYPEhas a single use. Inline it. - N6
live/spec.ts. Every live scenario now carriesfieldMappings, so nothing live exercises a v1 config with nofieldMappings. Unit coverage exists (routerTransform.test.ts:539). Optionally keep one live v1 scenario without the key.
Questions
- What does rudder-sources (
mappers/record.go:119-123, passes column JSON through) emit for Snowflake TIMESTAMP_NTZ and NUMBER(38,0)? Does it send ISO withZ, and numeric strings? If epoch ms arrives as a string such as"1760000000000", DATE_TIME leaves it out on every run (verified). NUMBER, by contrast, accepts numeric strings. This is spec §8 Q2 and is unverified. - Is "flag lost while a trait attribute is broken in PX" (S3) an accepted product trade-off? The alternative is a flag-only request plus a traits request, which doubles the PX quota. If it is accepted, the customer guide line in spec §6 is the only mitigation.
- PX sandbox results for NUMBER (int-only?) and DATE_TIME (string accepted? negative?): the PR body says these are pending.
Can be deleted (minimal scope)
- The
MAX_TRAIT_MAPPINGScap and its test (N0). - The
typeternary (N4). - The
LOG_DEST_TYPEconstant (N5). ZONELESS_DATE_TIMEplus theDate.parsefallback, folded into one strict ISO regex (S2).
What I checked / ran
- Read the full diff:
traits.ts,routerTransform.ts,delivery.ts,types.ts,config.ts, tests and fixtures. Read spec #229trait-mappings.md. - Unit tests:
jest -c jest.config.typescript.js src/v0/destinations/gainsight_px_audienceunder Node 22, 3 suites, 114/114 pass. - Component tests:
component.test.ts --destination=gainsight_px_audience. 21/21 pass, covering router, EU base URL, 404 leave/member, 400 abort, 429 throttled and 500 retry. - Probe: a throwaway jest file ran
convertTraitValueandcollectTraitsover ~50 inputs underTZ=UTCandTZ=America/Los_Angeles. Inputs included null,"", NaN, Infinity, numeric strings, booleans, a 100k-char string, zone-less and offset dates, non-ISO dates, epoch s and ms as numbers and strings, a fractional epoch,1e20,__proto__/constructor, duplicateto, and 60 rows. The S1, S2, N0 and N1–N3 results come from this run. - v1 back-compat:
- The test diff removes no assertions; only the
buildConnectionsignature widened. - Router and dataDelivery v1 fixtures are untouched and pass.
- With no
fieldMappings,collectTraits(undefined)returns{}, so the body is{flag:true}/{flag:false}, identical to v1. isLeave(delivery.ts:27-35) gives the same verdict as the oldsentValuefor v1 bodies.
- The test diff removes no assertions; only the
- Leavers:
routerTransform.ts:73-76writes{flag:false}only and never readsfields. Tests atrouterTransform.test.ts:331and router fixture 6 cover it. - Config: read per row from
connection.config.destination.fieldMappings(routerTransform.ts:64,74), schemaz.unknown()(types.ts:32). When/setupis skipped, untyped rows are left out asunknown_type, so they are never sent raw. - Batching: one record per PUT (
routerTransform.ts:94-97), with flag and traits in the same body. A trait rejection therefore fails the flag (S1/S3). - Logging: one warn per pass per (attribute, reason) with no values or ids (
routerTransform.ts:120-126). There is a new instance per request and passes run sequentially (processDestinationIntegration.ts:220,253,260), so the instance map is safe. - House pattern: no other audience destination in this repo reads
message.fields(grep across braze/iterable/customerio/hs/linkedin audience), so there is no trait-conversion precedent to copy.hs_audience/routerTransform.ts:104already overridestransformEvents. - Not verified: PX acceptance of floats, large numbers, long strings or DATE_TIME edge values; rudder-sources value serialisation per warehouse; live runs (none were run).
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #5703 +/- ##
===========================================
+ Coverage 92.28% 92.30% +0.02%
===========================================
Files 731 732 +1
Lines 40616 40726 +110
Branches 9513 9480 -33
===========================================
+ Hits 37484 37594 +110
- Misses 2868 2948 +80
+ Partials 264 184 -80 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
- DATE_TIME numbers must be integers in 0..8.64e15 (PX 400s fractional, negative and 1e20); strings are strict ISO-8601 only, parsed to epoch ms (zone-less is UTC), never sent as strings (PX stores them as 0) - NUMBER strings must be decimal text (no hex/binary) - drop the 50-row cap, the type ternary and LOG_DEST_TYPE - stop logging null values: normal for nullable columns - reword the "never blocks the flag" comments to what the code can promise Co-Authored-By: Claude Opus 5.5 <[email protected]>
… strings Parsed ISO strings now go through the same 0..8.64e15 integer rule as numbers (PX 400s negative values), and impossible calendar dates such as 2026-02-30 are left out instead of rolling over into March. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@am6010 thanks for the thorough review. Every point is addressed or answered below. The live PX sandbox probe (2026-10-20) settled the NUMBER/DATE_TIME questions: DATE_TIME takes only integer epoch ms (fractional, negative and 1e20 → 400; an ISO string → 204 but stored as 0), NUMBER takes any finite number but not a numeric string, and STRING is cut to 2000 chars. The deploy order is now transformer → webapp + Lookout → integrations-info (spec §7). rudder-transformer #5703 replies (fix in 2aa3486)
re-review
Mini verification against the PX sandbox: 17 PASS, 0 FAIL (rudder-specs#229 |
am6010
left a comment
There was a problem hiding this comment.
Re-reviewed 02bb5f2e7..c9bcca00c. Every point from my review is addressed as described, and 140/140 unit + 21/21 component tests pass under both UTC and America/Los_Angeles.
- S1/S2: DATE_TIME is always an integer epoch ms in 0..8.64e15. I probed the strict ISO parser with
+05:30/+0530/+05, fractional seconds, leap days,2026-02-30,T24:00, lowercaset/zand padding: correct, and independent of the host time zone. NUMBER strings are converted to numbers, so PX's 400 on "7" can't happen. - Optional nit: a space before the zone (
"2026-10-20 10:00:00.000 -0700","... UTC") is now left out, whereDate.parseused to read it correctly. That only matters if Q1 shows rudder-sources sends text timestamps. - Optional nit: epoch seconds still lands in 1970 (PX 204). Worth one line in the customer guide.
|



What
Members are written
{ <flag>: true, ...traits }(flag first); leavers{ <flag>: false }only, so traits keep their last value.traits.tsconverts each trait to its stored PXtype(STRING/NUMBER/BOOLEAN/DATE_TIME; zone-less date-times as UTC; blank strings are not numbers); a null, unconvertible or untyped value is left out, so a value the transformer cannot convert never blocks the flag (PX rejects the whole write on one bad value). PX-side rejections still do — e.g. a trait attribute disabled or retyped in PX after setup. Malformed API-savedfieldMappingsare parsed leniently. Onewarnper transform pass per (attribute, reason) with a count — never values or IDs. Delivery: a 404 is success only for a leave (exactly one key, valuefalse). New router/dataDelivery fixtures and live scenarios.Spec: rudder-specs#229 —
trait-mappings.md(D17–D26), extending GPX Audience v1 (rudder-specs#216). Context: Cvent asked for membership flags and trait sync (2026-10-16).Pre-ready review. Per-task spec+quality review, then a whole-branch cross-repo review (setup output ↔ client save paths ↔ transformer schema; listFields shape ↔ client splits; type stamping; leave detection; privacy; v1 back-compat). Final-review fixes re-reviewed. Deferred minors and rulings are in the spec PR's plan ledger.
Verification on rudder-mini against the PX sandbox (report: rudder-specs#229
verify/2026-10-20-trait-mappings-mini-verification.md): 20/20 PASS, 0 FAIL on the current heads (info 290f998, transformer c9bcca0, webapp 7eaa99b29, Lookout 4c7631480): flag + STRING/NUMBER/DATE_TIME traits end to end, leave keeps traits, unconvertible values left out with the flag still landing (incl. a pre-1970 date), 404 verdicts, mapping change → full sync, webapp and Lookout create/edit/remove-all, pre-v1.1 activations unchanged; live specs info 8/8, transformer 7/7. Reviewer feedback addressed (see comments).Deploy order (spec §7): integrations-info and transformer first, then webapp and Lookout. No new flag; behind the v1 gates.
🤖 Generated with Claude Code