Skip to content

[STRATCONN-6647]-HubSpot<->Segment is converting the empty strings to 0 in the event payload#3755

Open
arnav777dev wants to merge 10 commits into
mainfrom
hubspot-empty-str
Open

[STRATCONN-6647]-HubSpot<->Segment is converting the empty strings to 0 in the event payload#3755
arnav777dev wants to merge 10 commits into
mainfrom
hubspot-empty-str

Conversation

@arnav777dev
Copy link
Copy Markdown
Contributor

@arnav777dev arnav777dev commented Apr 27, 2026

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)

  • Throws a clear error (PayloadValidationError) when a non-numeric string is sent to a field that HubSpot has typed as number, rather than silently failing
  • Removes temporary instrumentation (stats metric + warning log for hubspot.custom_event.empty_string_to_number) that was added to monitor the issue

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.

  • Reviewed all field definitions for sensitive data (API keys, tokens, passwords, client secrets) and confirmed they use type: 'password'

New Destination Checklist

  • Extracted all action API versions to verioning-info.ts file. example

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 cleanPropObj number-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
Copy link
Copy Markdown

codecov Bot commented Apr 27, 2026

Codecov Report

❌ Patch coverage is 86.20690% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.93%. Comparing base (48b53d2) to head (f539a9d).
⚠️ Report is 16 commits behind head on main.

Files with missing lines Patch % Lines
...s/hubspot/customEvent/functions/cache-functions.ts 83.33% 2 Missing and 1 partial ⚠️
...mEvent/functions/hubspot-event-schema-functions.ts 75.00% 0 Missing and 1 partial ⚠️
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.
📢 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.

@arnav777dev arnav777dev changed the title Hubspot empty str [STRATCONN-6647]-HubSpot<->Segment is converting the empty strings to 0 in the event payload Apr 27, 2026
@arnav777dev arnav777dev marked this pull request as ready for review April 27, 2026 10:36
@arnav777dev arnav777dev requested a review from a team as a code owner April 27, 2026 10:36
Copilot AI review requested due to automatic review settings April 27, 2026 10:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

@joe-ayoub-segment
Copy link
Copy Markdown
Contributor

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.

Copilot AI review requested due to automatic review settings April 29, 2026 13:15
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Copilot AI review requested due to automatic review settings April 29, 2026 14:02
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

joe-ayoub-segment and others added 2 commits April 29, 2026 15:05
…ent/functions/validation-functions.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 29, 2026 14:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

@joe-ayoub-segment joe-ayoub-segment self-assigned this May 5, 2026
@joe-ayoub-segment
Copy link
Copy Markdown
Contributor

Hi @sayan-das-in I added testing screenshots from staging to the description above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants