Skip to content

Fix EventbridgeClient: send PutEvents Time as a Date (SDK v3) - #21

Merged
billfreeman44 merged 1 commit into
masterfrom
fix/eventbridge-time-date
Jul 7, 2026
Merged

Fix EventbridgeClient: send PutEvents Time as a Date (SDK v3)#21
billfreeman44 merged 1 commit into
masterfrom
fix/eventbridge-time-date

Conversation

@billfreeman44

Copy link
Copy Markdown
Member

Problem

EventbridgeClient.putEvents sends the entry Time as an ISO string. Under AWS SDK v3, PutEventsCommand rejects that with:

SerializationException: STRING_VALUE can not be converted to milliseconds since epoch  (HTTP 400)

formatEventInput normalized the event's time to an ISO string and passed it straight through:

evolve({
  detail: toJson,
  time: compose(toIso, fromIsoUtc)   // <- ISO string
})

SDK v2 tolerated a timestamp string; v3 requires a real Date. This is the same class of bug that broke blobd's eventbridge-put-events handler after its v3 migration (fixed there in 3.1.0).

Impact: latent today — no current caller passes a top-level time (event emitters use { detail, detailType, source }), so EventBridge defaults Time to ingestion time. But the moment any event carries a time, it fails. This removes the landmine.

Fix

Wrap the normalized value in a Date so the SDK marshals it correctly:

time: compose((iso) => new Date(iso), toIso, fromIsoUtc)

Normalization via fromIsoUtc/toIso is preserved; only the final type handed to the SDK changes (string → Date).

Validation

  • npx ava lib/clients/eventbridge.spec.js6/6 pass (spec updated to expect Time: new Date(...)).
  • Prettier: content-clean (the local --check warning is the repo's known CRLF-vs-LF false positive; CI runs on LF).

🤖 Generated with Claude Code

formatEventInput normalized an event's `time` to an ISO string
(compose(toIso, fromIsoUtc)) and handed it to PutEventsCommand. Under
aws-sdk v3 that throws "SerializationException: STRING_VALUE can not be
converted to milliseconds since epoch"; v2 tolerated the string. Wrap the
normalized value in a Date so the SDK marshals it correctly.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

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 fixes EventbridgeClient.putEvents for AWS SDK v3 by ensuring the Time field in PutEventsCommand entries is sent as a Date object (not an ISO string), preventing the SDK v3 SerializationException when callers provide an event time.

Changes:

  • Update formatEventInput to convert the normalized ISO timestamp into a Date before passing it to the AWS SDK.
  • Update the EventBridge client spec to expect Time as a Date.
  • Document the fix in CHANGELOG.md (v3.0.3).

Reviewed changes

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

File Description
lib/clients/eventbridge.js Converts normalized time to a Date so AWS SDK v3 can serialize Time correctly.
lib/clients/eventbridge.spec.js Adjusts expectations so the mocked PutEventsCommand includes Time: new Date(...).
CHANGELOG.md Adds a release note describing the SDK v3 compatibility fix for Time.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@billfreeman44
billfreeman44 merged commit 5ce85ef into master Jul 7, 2026
10 checks passed
@billfreeman44
billfreeman44 deleted the fix/eventbridge-time-date branch July 7, 2026 23:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants