fix(httpapi): encode event stream timestamps as epoch millis#28852
Open
faern wants to merge 2 commits into
Open
fix(httpapi): encode event stream timestamps as epoch millis#28852faern wants to merge 2 commits into
faern wants to merge 2 commits into
Conversation
Effect `DateTime` values serialize through `toJSON()` as ISO 8601 strings. The `/event` and `/global/event` SSE handlers ran bus payloads through a plain `JSON.stringify`, so every `session.next.*` event sent its `timestamp` as a string. The OpenAPI spec declares `timestamp` as a number (the encoded form of `V2Schema.DateTimeUtcFromMillis`), so a strict typed client cannot decode any `session.next.*` event and the event stream dies on the first prompt. Encode `DateTime` values to epoch millis before serializing, matching the spec and every other timestamp in the API.
Guard against regressing the `session.next.*` `timestamp` wire format. Tests assert epoch-millis numbers on the `/event` and `/global/event` SSE streams, and that `eventData` encodes nested `DateTime` values.
Contributor
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
timestamp wire format in session.next.* events.
timestamp wire format in session.next.* events.
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.
Issue for this PR
Closes #28847
Type of change
What does this PR do?
The OpenAPI spec declares
session.next.*eventtimestampas a number (epoch millis), but the SSE streams sent it as an ISO 8601 string. Bus payloads carry EffectDateTimeobjects, andJSON.stringifyserializes those viaDateTime.toJSON()(ISO string) instead of the schema-encoded epoch millis. The sharedeventDataSSE serializer now walks the payload and converts anyDateTimeto epoch millis before stringifying, so/eventand/global/eventmatch the spec.
The vast majority of this PR adds the tests. The first commit is the actual fix. We can merge only the fix if you think the tests add too much complexity.
How did you verify your code works?
I ran a build of this branch locally and interacted with the API, making sure it now returns the unix epoch integer. I also added regression tests for
/event,/global/event(nested sync events), and theeventDataserializer. Also ran the full opencode test suite, typecheck, and the httpapi exerciser gates locally.Checklist