Skip to content

Raise on invalid timestamps instead of silently dropping#144

Merged
hownowstephen merged 1 commit into
mainfrom
fix/timestamp-validation
May 22, 2026
Merged

Raise on invalid timestamps instead of silently dropping#144
hownowstephen merged 1 commit into
mainfrom
fix/timestamp-validation

Conversation

@hownowstephen
Copy link
Copy Markdown
Contributor

@hownowstephen hownowstephen commented May 22, 2026

Summary

  • track(), track_anonymous(), and track_delivery_metric() previously silently discarded invalid timestamps (milliseconds, strings, Time objects) — now they raise ParamError with a descriptive message
  • Consistent with track_push_notification_event which already raised on invalid timestamps
  • Added validate_timestamp! private helper to centralize validation

Breaking change

Users relying on silent discard of invalid timestamps will now get Customerio::Client::ParamError. This is intentional — silent data loss is worse than a loud error.

Test plan

  • Updated 3 tests in #track from "silently drops" to "raises ParamError"
  • Updated 1 test in #track_delivery_metric from "silently drops" to "raises ParamError"
  • All 130 examples pass
  • RuboCop clean

Note

Medium Risk
This changes public client behavior by turning previously ignored invalid timestamp inputs into hard errors, which is a breaking change for callers. Logic is localized to timestamp validation but affects common tracking methods.

Overview
Stops silently dropping invalid timestamp values in track/track_anonymous event creation and track_delivery_metric; invalid timestamps now raise Customerio::Client::ParamError.

Adds a shared validate_timestamp! helper and updates event creation to prefer timestamp keyword arg over attributes[:timestamp] while validating the chosen value, with specs updated to expect errors for milliseconds, non-integers, and Time objects.

Reviewed by Cursor Bugbot for commit 49a85e2. Bugbot is set up for automated code reviews on this repo. Configure here.

Previously track(), track_anonymous(), and track_delivery_metric()
silently discarded invalid timestamps (milliseconds, strings, Time
objects). This was inconsistent with track_push_notification_event
which raises ParamError. Now all methods raise ParamError with a
descriptive message when an invalid timestamp is provided.
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 49a85e2. Configure here.

Comment thread lib/customerio/client.rb
@hownowstephen hownowstephen merged commit 6cb4b95 into main May 22, 2026
9 checks passed
@hownowstephen hownowstephen deleted the fix/timestamp-validation branch May 22, 2026 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants