-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Added test and fix for wrong time format and serialization in events v2 #11959
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
LocalStack Community integration with Pro 2 files ± 0 2 suites ±0 1h 7m 50s ⏱️ - 41m 6s Results for commit 5610d08. ± Comparison against base commit 892eb4d. This pull request removes 1541 and adds 3 tests. Note that renamed tests count towards both.
♻️ This comment has been updated with latest results. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTMT - nice implementation - I belive we had a custom json encoder at one point for serialization
@@ -919,7 +919,7 @@ class EventSource(TypedDict, total=False): | |||
|
|||
|
|||
EventSourceList = List[EventSource] | |||
EventTime = datetime | |||
EventTime = Union[datetime, str] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe use the newer recommended way datetime | str
@@ -130,6 +130,11 @@ def get_event_time(event: PutEventsRequestEntry) -> EventTime: | |||
return event_time | |||
|
|||
|
|||
def format_event_time(event_time: datetime) -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why would we need the same function 2 times? just use event_time_to_time_string
?
Motivation
Found through an issue: #11630
When using EventBridge v2, events containing datetime fields fail to be delivered due to JSON serialization error:
Object of type datetime is not JSON serializable
. This affects events with explicit Time fields as well as automatically generated timestamps.Changes
format_event_time
function to properly format datetime objects to ISO8601 stringsformat_event
to use the formatted time stringThe fix ensures proper datetime handling in events while maintaining AWS parity by formatting all time values to ISO8601 strings (YYYY-MM-DDThh:mm:ssZ).