Skip to content

Commit 16ddf5f

Browse files
authored
fix(session): use finite archived timestamp schema (#25275)
1 parent 8c79c58 commit 16ddf5f

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

packages/opencode/src/session/session.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ const Share = Schema.Struct({
142142
url: Schema.String,
143143
})
144144

145-
// Legacy HTTP accepted any number here, and persisted data may already contain
146-
// negative values. Keep archive timestamps permissive while other clocks stay non-negative.
147-
export const ArchivedTimestamp = Schema.Number
145+
// Legacy HTTP accepted negative values here. Keep archive timestamps permissive
146+
// while excluding non-finite values that cannot round-trip through JSON.
147+
export const ArchivedTimestamp = Schema.Finite
148148

149149
const Time = Schema.Struct({
150150
created: NonNegativeInt,

packages/opencode/test/server/httpapi-bridge.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,18 @@ describe("HttpApi server", () => {
258258
})
259259
})
260260

261+
test("matches SDK-affecting request schema details", () => {
262+
const effect = effectOpenApi()
263+
const sessionUpdate = effect.paths["/session/{sessionID}"]?.patch?.requestBody
264+
const sessionUpdateSchema =
265+
typeof sessionUpdate === "object" && sessionUpdate && "content" in sessionUpdate
266+
? sessionUpdate.content?.["application/json"]?.schema
267+
: undefined
268+
const sessionUpdateProperties = sessionUpdateSchema?.properties as Record<string, OpenApiSchema> | undefined
269+
const time = sessionUpdateProperties?.time
270+
expect(time?.properties?.archived).toEqual({ type: "number" })
271+
})
272+
261273
test("documents event routes as server-sent events", () => {
262274
const effect = effectOpenApi()
263275

0 commit comments

Comments
 (0)