Fix EventbridgeClient: send PutEvents Time as a Date (SDK v3) - #21
Merged
Conversation
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>
There was a problem hiding this comment.
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
formatEventInputto convert the normalized ISO timestamp into aDatebefore passing it to the AWS SDK. - Update the EventBridge client spec to expect
Timeas aDate. - 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
EventbridgeClient.putEventssends the entryTimeas an ISO string. Under AWS SDK v3,PutEventsCommandrejects that with:formatEventInputnormalized the event'stimeto an ISO string and passed it straight through:SDK v2 tolerated a timestamp string; v3 requires a real
Date. This is the same class of bug that broke blobd'seventbridge-put-eventshandler 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 defaultsTimeto ingestion time. But the moment any event carries atime, it fails. This removes the landmine.Fix
Wrap the normalized value in a
Dateso the SDK marshals it correctly:Normalization via
fromIsoUtc/toIsois preserved; only the final type handed to the SDK changes (string →Date).Validation
npx ava lib/clients/eventbridge.spec.js→ 6/6 pass (spec updated to expectTime: new Date(...)).--checkwarning is the repo's known CRLF-vs-LF false positive; CI runs on LF).🤖 Generated with Claude Code