chore: add error logs (#815)

* chore: add error logs

* chore: add error logs
This commit is contained in:
Brace Sproul 2025-08-29 17:25:17 -07:00 • committed by GitHub
parent 8c1fbfac3c
commit 998655385b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 37 additions and 3 deletions

View file

@ -68,7 +68,8 @@ export async function getInstallationNameFromReq(
installationId: string,
): Promise<string> {
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 "";
}
}

View file

@ -105,7 +105,8 @@ async function createNewSession(
*/
export async function POST(request: NextRequest): Promise<NextResponse> {
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<NextResponse> {
);
}
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,