fix(httpapi): expose unavailable v2 session mutations (#28624)
This commit is contained in:
@@ -115,4 +115,18 @@ describe("PublicApi OpenAPI v2 errors", () => {
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
test("documents v2 unfinished session mutation errors", () => {
|
||||
const spec = OpenApi.fromApi(PublicApi) as OpenApiSpec
|
||||
|
||||
for (const route of [
|
||||
["post", "/api/session/{sessionID}/prompt"],
|
||||
["post", "/api/session/{sessionID}/compact"],
|
||||
["post", "/api/session/{sessionID}/wait"],
|
||||
] as const) {
|
||||
expect(componentName(responseRef(spec.paths[route[1]]?.[route[0]]?.responses?.["503"]) ?? "")).toBe(
|
||||
"ServiceUnavailableError",
|
||||
)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -442,6 +442,45 @@ describe("session HttpApi", () => {
|
||||
{ git: true, config: { formatter: false, lsp: false } },
|
||||
)
|
||||
|
||||
it.instance(
|
||||
"returns v2 public unavailable errors for unfinished session mutations",
|
||||
() =>
|
||||
Effect.gen(function* () {
|
||||
const test = yield* TestInstance
|
||||
const headers = { "x-opencode-directory": test.directory }
|
||||
const session = yield* createSession({ title: "v2 unavailable" })
|
||||
|
||||
const prompt = yield* request(`/api/session/${session.id}/prompt`, {
|
||||
method: "POST",
|
||||
headers: { ...headers, "content-type": "application/json" },
|
||||
body: JSON.stringify({ prompt: { text: "hello" } }),
|
||||
})
|
||||
expect(prompt.status).toBe(503)
|
||||
expect(yield* responseJson(prompt)).toEqual({
|
||||
_tag: "ServiceUnavailableError",
|
||||
message: "V2 session prompt is not available yet",
|
||||
service: "v2.session.prompt",
|
||||
})
|
||||
|
||||
const compact = yield* request(`/api/session/${session.id}/compact`, { method: "POST", headers })
|
||||
expect(compact.status).toBe(503)
|
||||
expect(yield* responseJson(compact)).toEqual({
|
||||
_tag: "ServiceUnavailableError",
|
||||
message: "V2 session compact is not available yet",
|
||||
service: "v2.session.compact",
|
||||
})
|
||||
|
||||
const wait = yield* request(`/api/session/${session.id}/wait`, { method: "POST", headers })
|
||||
expect(wait.status).toBe(503)
|
||||
expect(yield* responseJson(wait)).toEqual({
|
||||
_tag: "ServiceUnavailableError",
|
||||
message: "V2 session wait is not available yet",
|
||||
service: "v2.session.wait",
|
||||
})
|
||||
}),
|
||||
{ git: true, config: { formatter: false, lsp: false } },
|
||||
)
|
||||
|
||||
it.instance(
|
||||
"serves sessions with migrated summary diffs missing file details",
|
||||
() =>
|
||||
|
||||
Reference in New Issue
Block a user