Skip to content

fix(hubspot): allow string values to match datetime fields in schema comparison#3827

Open
harsh-joshi99 wants to merge 3 commits into
mainfrom
fix/hubspot-custom-object-datetime-string-coercion
Open

fix(hubspot): allow string values to match datetime fields in schema comparison#3827
harsh-joshi99 wants to merge 3 commits into
mainfrom
fix/hubspot-custom-object-datetime-string-coercion

Conversation

@harsh-joshi99

@harsh-joshi99 harsh-joshi99 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • HubSpot datetime fields accept plain string values such as Unix epoch timestamps (e.g. "1780382814" or "1780382814000"), but our schema comparison in compareProps() was classifying these as string:text and rejecting them against HubSpot's datetime:date fields
  • Added a coercion rule allowing string:text (payload-inferred) to match datetime:date (HubSpot schema), consistent with the existing rules for string:text → enumeration:select and string:text → string:textarea
  • HubSpot is the right place to validate the actual value — if someone sends an invalid string, HubSpot will 400 them directly

JIRA: https://twilio-engineering.atlassian.net/browse/STRATCONN-6042

Root Cause

BigQuery RETL serializes timestamp columns as Unix epoch strings. When these arrive in the upsertObject action, format() correctly identifies them as plain strings (they don't match the ISO datetime regex), tagging them string:text. compareProps() then sees string:text vs datetime:date and throws a type mismatch error before the request ever reaches HubSpot.

Test plan

Local Testing:
Screenshot 2026-06-09 at 11 13 22 AM

  • Added unit test to upsert-property-mismatch.test.ts confirming epoch string "1780382814" passes schema comparison against a datetime:date HubSpot field without throwing
  • Added unit tests to new schema-functions.test.ts covering format() type detection for all value types (date string, datetime string, epoch string, number, boolean, plain string)
  • All 41 existing upsertObject tests pass
  • Verified end-to-end in sandbox: "1780382814000" sent to hs_appointment_start (datetime:date) resulted in a 201 Created with HubSpot storing the value as "2026-06-02T06:46:54Z"

🤖 Generated with Claude Code

…comparison

HubSpot datetime fields accept plain string values such as Unix epoch
timestamps. The schema comparison was incorrectly blocking these by
classifying them as string:text and rejecting them against datetime:date
fields. Added a coercion rule in compareProps() consistent with existing
string:text -> enumeration:select and string:text -> string:textarea rules.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@harsh-joshi99 harsh-joshi99 requested a review from a team as a code owner June 9, 2026 05:44
Copilot AI review requested due to automatic review settings June 9, 2026 05:44

Copilot AI 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.

Pull request overview

This PR updates HubSpot upsertObject schema comparison to treat payload-inferred string:text values as compatible with HubSpot datetime:date fields, unblocking Unix-epoch timestamp strings that otherwise fail strict type matching before requests reach HubSpot validation.

Changes:

  • Added a schema-compatibility rule in compareProps() to allow string:text to match datetime:date.
  • Added an integration test ensuring an epoch string payload no longer fails schema comparison.
  • Added unit tests covering format() type detection for representative value shapes.

Reviewed changes

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

File Description
packages/destination-actions/src/destinations/hubspot/upsertObject/functions/schema-functions.ts Adds a coercion rule in compareProps() to accept epoch-like string values for HubSpot datetime fields.
packages/destination-actions/src/destinations/hubspot/upsertObject/__tests__/upsert-property-mismatch.test.ts Adds a regression test ensuring epoch strings don’t fail before calling HubSpot.
packages/destination-actions/src/destinations/hubspot/upsertObject/__tests__/schema-functions.test.ts Adds new unit tests for objectSchema()/format() type detection across common input types.

Comment on lines +169 to +177
if (
prop1.type === HSPropType.String &&
prop1.fieldType === HSPropFieldType.Text &&
prop2.type === HSPropType.DateTime &&
prop2.fieldType === HSPropFieldType.Date
) {
// string values (e.g. Unix epoch strings) are valid for HubSpot datetime fields
return true
}
…tibility

When the cache stores a payload-inferred string:text schema (from an epoch
string event) and a subsequent event sends an ISO datetime string
(inferred as datetime:date), the cache comparison would throw a mismatch.
Making the coercion bidirectional prevents time-dependent failures when
the same HubSpot datetime property arrives in different string encodings
across events.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 23, 2026 10:19

Copilot AI 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.

Pull request overview

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

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.

3 participants