diff --git a/apps/web/src/app/api/[..._path]/utils.ts b/apps/web/src/app/api/[..._path]/utils.ts index 53958052..5d3bf58b 100644 --- a/apps/web/src/app/api/[..._path]/utils.ts +++ b/apps/web/src/app/api/[..._path]/utils.ts @@ -68,7 +68,8 @@ export async function getInstallationNameFromReq( installationId: string, ): Promise { try { - const requestJson = await req.json(); + const reqCopy = req.clone(); + const requestJson = await reqCopy.json(); const installationName = requestJson?.input?.targetRepository?.owner; if (installationName) { return installationName; @@ -79,7 +80,8 @@ export async function getInstallationNameFromReq( try { return await getInstallationName(installationId); - } catch { + } catch (error) { + console.error("Failed to get installation name:", error); return ""; } } diff --git a/apps/web/src/app/api/restart-run/route.ts b/apps/web/src/app/api/restart-run/route.ts index f2639745..2a8b192d 100644 --- a/apps/web/src/app/api/restart-run/route.ts +++ b/apps/web/src/app/api/restart-run/route.ts @@ -105,7 +105,8 @@ async function createNewSession( */ export async function POST(request: NextRequest): Promise { try { - const body: RestartRunRequest = await request.json(); + const reqCopy = request.clone(); + const body: RestartRunRequest = await reqCopy.json(); const { managerThreadId, plannerThreadId, programmerThreadId } = body; const langGraphClient = new Client({ @@ -142,6 +143,37 @@ export async function POST(request: NextRequest): Promise { ); } + if (!("config" in managerThread)) { + console.error("Manager thread must have a config."); + console.dir(managerThread, { depth: null }); + return NextResponse.json( + { + error: "Failed to restart run. Manager thread must have a config.", + }, + { status: 500 }, + ); + } + if (!("config" in plannerThread)) { + console.error("Planner thread must have a config."); + console.dir(plannerThread, { depth: null }); + return NextResponse.json( + { + error: "Failed to restart run. Planner thread must have a config.", + }, + { status: 500 }, + ); + } + if (programmerThread && !("config" in programmerThread)) { + console.error("Programmer thread must have a config."); + console.dir(programmerThread, { depth: null }); + return NextResponse.json( + { + error: "Failed to restart run. Programmer thread must have a config.", + }, + { status: 500 }, + ); + } + const newProgrammerSession = programmerThreadState ? await createNewSession(langGraphClient, { graphId: PROGRAMMER_GRAPH_ID,