STRATCONN-4121 - [Customerio] - Support ISO timestamps with >3 fractional second digits - #3923
Conversation
dayjs only reliably parses up to 3 fractional second digits (milliseconds). Timestamps with 7-9 digits (e.g. 2024-08-14T20:36:48.6527521Z) were silently not converted to Unix format, causing downstream type errors. Add normalizeIsoFractionalSeconds() to trim sub-millisecond digits before dayjs parsing. Applied in both convertAttributeTimestamps and convertValidTimestamp. No precision is lost since Unix is second-level. Reported via STRATCONN-4121.
There was a problem hiding this comment.
Pull request overview
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Adds support for ISO-8601 timestamps containing more than 3 fractional-second digits (sub-millisecond precision) by normalizing them before parsing with dayjs, preventing silent “non-conversion” to Unix timestamps in Customer.io payload handling.
Changes:
- Introduced
normalizeIsoFractionalSeconds()to trim ISO fractional seconds to 3 digits before parsing. - Applied normalization in
convertValidTimestampandconvertAttributeTimestamps. - Added Jest tests for
convertAttributeTimestampscovering 7/9-digit fractional seconds and regressions.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/destination-actions/src/destinations/customerio/utils.ts | Normalizes ISO fractional seconds before dayjs parsing in timestamp conversion helpers. |
| packages/destination-actions/src/destinations/customerio/tests/utils.test.ts | Adds test coverage for convertAttributeTimestamps with higher-precision fractional seconds. |
|
Thanks for picking this up! 🙏 I dug into the two screenshots on STRATCONN-4121 and cloned the repo to test — I think this fix lands one step too late to actually resolve the issue. Repro / root causeIn Because Suggested fix — normalize before the
|
|
Superseded by #3930 |
Problem
The
convertAttributeTimestampsandconvertValidTimestampfunctions pass ISO timestamp strings directly todayjsfor parsing. dayjs only reliably handles up to 3 fractional second digits (milliseconds). Timestamps with 7+ fractional digits (e.g.2024-08-14T20:36:48.6527521Z) are silently not converted to Unix format, causing the raw string to be sent downstream instead of the expected integer.Reported via STRATCONN-4121 by a Twilio partner customer.
Fix
Add
normalizeIsoFractionalSeconds()— a one-liner that trims fractional seconds to 3 digits before passing to dayjs. Applied in both conversion functions. No precision is lost since Unix timestamps are second-level.Tests
Added test cases covering: