mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-27 17:28:50 +00:00
fix(httpapi): model optional session payloads as no content (#29247)
This commit is contained in:
parent
a5ea910eac
commit
a99ebd1d65
2 changed files with 27 additions and 1 deletions
|
|
@ -236,7 +236,7 @@ export const SessionApi = HttpApi.make("session")
|
|||
HttpApiEndpoint.post("fork", SessionPaths.fork, {
|
||||
params: { sessionID: SessionID },
|
||||
query: WorkspaceRoutingQuery,
|
||||
payload: Schema.optional(ForkPayload),
|
||||
payload: [HttpApiSchema.NoContent, ForkPayload],
|
||||
success: described(Session.Info, "200"),
|
||||
error: [HttpApiError.BadRequest, ApiNotFoundError],
|
||||
}).annotateMerge(
|
||||
|
|
|
|||
|
|
@ -602,6 +602,32 @@ describe("session HttpApi", () => {
|
|||
})
|
||||
expect(forked.id).not.toBe(created.id)
|
||||
|
||||
const forkedWithoutContentType = yield* requestJson<Session.Info>(
|
||||
pathFor(SessionPaths.fork, { sessionID: created.id }),
|
||||
{
|
||||
method: "POST",
|
||||
headers: { "x-opencode-directory": test.directory },
|
||||
},
|
||||
)
|
||||
expect(forkedWithoutContentType.id).not.toBe(created.id)
|
||||
|
||||
const invalidFork = yield* request(pathFor(SessionPaths.fork, { sessionID: created.id }), {
|
||||
method: "POST",
|
||||
headers,
|
||||
body: "{",
|
||||
})
|
||||
expect(invalidFork.status).toBe(400)
|
||||
|
||||
const forkedWhitespace = yield* requestJson<Session.Info>(
|
||||
pathFor(SessionPaths.fork, { sessionID: created.id }),
|
||||
{
|
||||
method: "POST",
|
||||
headers,
|
||||
body: " \n",
|
||||
},
|
||||
)
|
||||
expect(forkedWhitespace.id).not.toBe(created.id)
|
||||
|
||||
expect(
|
||||
yield* requestJson<boolean>(pathFor(SessionPaths.abort, { sessionID: created.id }), {
|
||||
method: "POST",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue