[STRATCONN-6647]-HubSpot<->Segment is converting the empty strings to 0 in the event payload#3755
[STRATCONN-6647]-HubSpot<->Segment is converting the empty strings to 0 in the event payload#3755arnav777dev wants to merge 10 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates HubSpot Custom Event payload validation to avoid incorrectly coercing empty/whitespace-only strings into numeric 0, improving the fidelity of custom event properties sent to HubSpot.
Changes:
- Refined
cleanPropObjnumber-coercion logic to only cast non-empty, non-whitespace string values to numbers. - Added a unit test covering empty string and whitespace-only string handling (and ensuring numeric strings still coerce as expected).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
packages/destination-actions/src/destinations/hubspot/customEvent/functions/validation-functions.ts |
Tightens numeric casting to prevent empty/whitespace strings from being converted to 0. |
packages/destination-actions/src/destinations/hubspot/customEvent/__tests__/validate.test.ts |
Adds coverage for empty/whitespace string property behavior during validation. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #3755 +/- ##
==========================================
- Coverage 81.11% 80.93% -0.19%
==========================================
Files 1656 1348 -308
Lines 32120 25107 -7013
Branches 7102 5216 -1886
==========================================
- Hits 26055 20320 -5735
+ Misses 5092 3839 -1253
+ Partials 973 948 -25 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Hi @arnav777dev - LGTM - only comment is about safety of rolling this out to customers who are already using the integration. If a user previously had an event schema field type set to number (because of the 0 value), then when we deploy this change the integration will likely start throwing errors saying that there's now a schema mismatch. For this reason I think it might be worth rolling out this change behind a flag. and to add instrumentation to detect when such an error occurs. |
…ent/functions/validation-functions.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Hi @sayan-das-in I added testing screenshots from staging to the description above. |
Fixes a bug where empty strings ("") sent as event properties were incorrectly coerced to 0 during payload validation (because Number("") === 0 in JavaScript), which caused HubSpot to create new fields as number type and corrupted string field values.
Preserves backward compatibility by introducing a convertStringToNumbers function that only coerces empty strings to 0 when HubSpot already has the field typed as number (for fields that were previously affected by the bug)
Testing
Tested in stage: https://docs.google.com/document/d/19PHvFVLWFn_BFPsFyQ2zzB9uJ27IxvEsEinjdwyCd7c/edit?tab=t.ug9nscg6b9ji
Security Review
Please ensure sensitive data is properly protected in your integration.
type: 'password'New Destination Checklist
verioning-info.tsfile. example