fix(app): handle nullable detail consumers

This commit is contained in:
Gabriel Brown
2026-07-10 17:24:32 -04:00
parent ed21126eea
commit 2beeeb1732
4 changed files with 103 additions and 2 deletions
@@ -1,3 +1,4 @@
import type { FunctionReturnType } from 'convex/server';
import { NextResponse } from 'next/server';
import { proxyWorker } from '@/lib/agent-worker-proxy';
import { convexAuthNextjsToken } from '@convex-dev/auth/nextjs/server';
@@ -35,7 +36,14 @@ export const POST = async (
{ status: 400 },
);
}
const details = await fetchQuery(api.threads.get, { threadId }, { token });
const details = (await fetchQuery(
api.threads.get,
{ threadId },
{ token },
)) as FunctionReturnType<typeof api.threads.get> | null;
if (details === null) {
return NextResponse.json({ error: 'Thread not found.' }, { status: 404 });
}
const latestJob = details.latestJob;
const canSendToWorker =
latestJob &&