fix(worktree): accept missing create payload (#27582)

This commit is contained in:
Kit Langton
2026-05-14 14:25:22 -04:00
committed by GitHub
parent d25cc42d21
commit d353a6bc24
2 changed files with 46 additions and 1 deletions

View File

@@ -166,8 +166,9 @@ export const ExperimentalApi = HttpApi.make("experimental")
}),
),
HttpApiEndpoint.post("worktreeCreate", ExperimentalPaths.worktree, {
disableCodecs: true,
query: WorkspaceRoutingQuery,
payload: Schema.optional(Worktree.CreateInput),
payload: Schema.UndefinedOr(Worktree.CreateInput),
success: described(Worktree.Info, "Worktree created"),
error: WorktreeApiError,
}).annotateMerge(

View File

@@ -129,6 +129,10 @@ function createWorktreeScoped(input: {
input.timeoutLabel,
input.timeoutMs,
)
if (response.status !== 200) {
const message = yield* Effect.promise(() => response.text())
throw new Error(`${input.timeoutLabel} failed: ${response.status} ${message}`)
}
expect(response.status).toBe(200)
const body = yield* json<CreatedWorktree>(response)
return { directory: body.directory, body, ready: waitReady(body.directory) } satisfies ScopedWorktree
@@ -186,6 +190,46 @@ describe("worktree endpoint reproduction", () => {
{ git: true },
)
worktreeTest(
"direct HttpApi worktree create accepts missing body",
() =>
Effect.gen(function* () {
const test = yield* TestInstance
const server = yield* serverScoped()
const response = yield* createWorktreeScoped({
server,
directory: test.directory,
path: `${ExperimentalPaths.worktree}?directory=${encodeURIComponent(test.directory)}`,
init: { method: "POST", headers: { "content-type": "application/json" } },
timeoutLabel: "direct worktree create without body",
})
expect(response).toMatchObject({ directory: expect.any(String) })
}),
{ git: true },
)
worktreeTest(
"direct HttpApi worktree create accepts missing content type and body",
() =>
Effect.gen(function* () {
const test = yield* TestInstance
const server = yield* serverScoped()
const response = yield* createWorktreeScoped({
server,
directory: test.directory,
path: `${ExperimentalPaths.worktree}?directory=${encodeURIComponent(test.directory)}`,
init: { method: "POST" },
timeoutLabel: "direct worktree create without content type or body",
})
expect(response).toMatchObject({ directory: expect.any(String) })
}),
{ git: true },
)
worktreeTest(
"workspace worktree create does not hang",
() =>